From 271756867a00ac88c8337710f5a287b0a0ba6fd3 Mon Sep 17 00:00:00 2001 From: anktd Date: Fri, 5 Apr 2024 17:29:48 +0530 Subject: [PATCH 01/13] setup PHPUnit, Mockery and WP_Mock for testing --- composer.json | 19 + composer.lock | 1987 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2006 insertions(+) create mode 100644 composer.json create mode 100644 composer.lock diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..dd39a260 --- /dev/null +++ b/composer.json @@ -0,0 +1,19 @@ +{ + "name": "blockonomics/test", + "require-dev": { + "phpunit/phpunit": "^9.5", + "mockery/mockery": "^1.5", + "10up/wp_mock": "^0.5.0" + }, + "autoload": { + "psr-4": { + "": "php/" + } + }, + "authors": [ + { + "name": "blockonomics", + "email": "webmaster@blockonomics.co" + } + ] +} diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..1ec806a9 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1987 @@ +{ + "_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#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "4aea6cf2201d71daeeacd29491957623", + "packages": [], + "packages-dev": [ + { + "name": "10up/wp_mock", + "version": "0.5.0", + "source": { + "type": "git", + "url": "https://github.com/10up/wp_mock.git", + "reference": "5cd57c63b1a946301ce0d7aaaa37cdc25805c163" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/10up/wp_mock/zipball/5cd57c63b1a946301ce0d7aaaa37cdc25805c163", + "reference": "5cd57c63b1a946301ce0d7aaaa37cdc25805c163", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.1", + "mockery/mockery": "^1.5", + "php": ">=7.3 < 9.0", + "phpunit/phpunit": "^9.5.24" + }, + "require-dev": { + "behat/behat": "^v3.11.0", + "php-coveralls/php-coveralls": "^v2.5.3", + "sebastian/comparator": "^4.0.8", + "sempro/phpunit-pretty-print": "^1.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "WP_Mock\\": "./php/WP_Mock" + }, + "classmap": [ + "php/WP_Mock.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "description": "A mocking library to take the pain out of unit testing for WordPress", + "support": { + "issues": "https://github.com/10up/wp_mock/issues", + "source": "https://github.com/10up/wp_mock/tree/0.5.0" + }, + "time": "2022-11-01T03:01:40+00:00" + }, + { + "name": "antecedent/patchwork", + "version": "2.1.28", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "6b30aff81ebadf0f2feb9268d3e08385cebcc08d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/6b30aff81ebadf0f2feb9268d3e08385cebcc08d", + "reference": "6b30aff81ebadf0f2feb9268d3e08385cebcc08d", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4" + }, + "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": "https://antecedent.github.io/patchwork/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "support": { + "issues": "https://github.com/antecedent/patchwork/issues", + "source": "https://github.com/antecedent/patchwork/tree/2.1.28" + }, + "time": "2024-02-06T09:26:11+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "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": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:23:10+00:00" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "time": "2020-07-09T08:09:16+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.6.11", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "81a161d0b135df89951abd52296adf97deb0723d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/81a161d0b135df89951abd52296adf97deb0723d", + "reference": "81a161d0b135df89951abd52296adf97deb0723d", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": ">=7.3" + }, + "conflict": { + "phpunit/phpunit": "<8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.6.17", + "symplify/easy-coding-standard": "^12.1.14" + }, + "type": "library", + "autoload": { + "files": [ + "library/helpers.php", + "library/Mockery.php" + ], + "psr-4": { + "Mockery\\": "library/Mockery" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "https://github.com/padraic", + "role": "Author" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "https://davedevelopment.co.uk", + "role": "Developer" + }, + { + "name": "Nathanael Esayeas", + "email": "nathanael.esayeas@protonmail.com", + "homepage": "https://github.com/ghostwriter", + "role": "Lead Developer" + } + ], + "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" + ], + "support": { + "docs": "https://docs.mockery.io/", + "issues": "https://github.com/mockery/mockery/issues", + "rss": "https://github.com/mockery/mockery/releases.atom", + "security": "https://github.com/mockery/mockery/security/advisories", + "source": "https://github.com/mockery/mockery" + }, + "time": "2024-03-21T18:34:15+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.11.1", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "reference": "7284c22080590fb39f2ffa3e9057f10a4ddd0e0c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3,<3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "type": "library", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.11.1" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2023-03-08T13:26:56+00:00" + }, + { + "name": "nikic/php-parser", + "version": "v5.0.2", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/139676794dc1e9231bf7bcd123cfc0c99182cb13", + "reference": "139676794dc1e9231bf7bcd123cfc0c99182cb13", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" + }, + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.0.2" + }, + "time": "2024-03-05T20:51:40+00:00" + }, + { + "name": "phar-io/manifest", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:33:53+00:00" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "time": "2022-02-21T01:04:05+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.31", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/48c34b5d8d983006bd2adc2d0de92963b9155965", + "reference": "48c34b5d8d983006bd2adc2d0de92963b9155965", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.2-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.31" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:37:42+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "3.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "reference": "cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-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": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-12-02T12:48:52+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-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": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-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": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-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": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "9.6.19", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1a54a473501ef4cdeaae4e06891674114d79db8", + "reference": "a1a54a473501ef4cdeaae4e06891674114d79db8", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.3.1 || ^2", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=7.3", + "phpunit/php-code-coverage": "^9.2.28", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.5", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^3.2", + "sebastian/version": "^3.0.2" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.6-dev" + } + }, + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "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" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.19" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2024-04-05T04:35:58+00:00" + }, + { + "name": "sebastian/cli-parser", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "reference": "2b56bea83a09de3ac06bb18b92f068e60cc6f50b", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "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", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:27:43+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "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", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2022-09-14T12:41:17+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/25f207c40d62b8b7aa32f5ab026c53561964053a", + "reference": "25f207c40d62b8b7aa32f5ab026c53561964053a", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:19:30+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/ba01945089c3a293b01ba9badc29ad55b106b0bc", + "reference": "ba01945089c3a293b01ba9badc29ad55b106b0bc", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:30:58+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "reference": "830c43a844f1f8d5b7a1f6d6076b784454d8b7ed", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-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" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:03:51+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/78c00df8f170e02473b682df15bfcdacc3d32d72", + "reference": "78c00df8f170e02473b682df15bfcdacc3d32d72", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:33:00+00:00" + }, + { + "name": "sebastian/global-state", + "version": "5.0.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "reference": "bca7df1f32ee6fe93b4d4a9abbf69e13a4ada2c9", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.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" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.7" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-02T06:35:11+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "reference": "e1e4a170560925c26d424b6a03aed157e7dcc5c5", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "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", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-12-22T06:20:34+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:12:34+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:14:26+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "4.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "reference": "e75bd0f07204fec2a0af9b0f3cfe97d05f92efc1", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:07:39+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "3.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "reference": "05d5692a7993ecccd56a03e40cd7e5b09b1d404e", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2024-03-14T16:00:52+00:00" + }, + { + "name": "sebastian/type", + "version": "3.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "reference": "75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-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": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/3.2.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2023-02-03T06:13:03+00:00" + }, + { + "name": "sebastian/version", + "version": "3.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c6c1022351a901512170118436c764e473f6de8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2024-03-03T12:36:25+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.6.0" +} From c44bbf7f233cd392501b7654fdc201e45a530691 Mon Sep 17 00:00:00 2001 From: anktd Date: Fri, 5 Apr 2024 17:31:47 +0530 Subject: [PATCH 02/13] exclude vendor directory from version control --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b512c09d..94b43113 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +vendor/ \ No newline at end of file From 3e98a9217a031f164eb0fbae14f582179fbe0ad2 Mon Sep 17 00:00:00 2001 From: anktd Date: Fri, 5 Apr 2024 17:46:38 +0530 Subject: [PATCH 03/13] Remove Mockery from composer dependencies --- composer.json | 1 - composer.lock | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index dd39a260..1e4963a6 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,6 @@ "name": "blockonomics/test", "require-dev": { "phpunit/phpunit": "^9.5", - "mockery/mockery": "^1.5", "10up/wp_mock": "^0.5.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index 1ec806a9..65c5710d 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": "4aea6cf2201d71daeeacd29491957623", + "content-hash": "60c30868d55781be2f7425f966d07fe5", "packages": [], "packages-dev": [ { From efda7ca25aae2913e8b11bdff91b1dafe426c6e7 Mon Sep 17 00:00:00 2001 From: anktd Date: Fri, 5 Apr 2024 17:49:30 +0530 Subject: [PATCH 04/13] Add tests for independent functions in php/Blockonomics.php --- tests/BlockonomicsTest.php | 114 +++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 tests/BlockonomicsTest.php diff --git a/tests/BlockonomicsTest.php b/tests/BlockonomicsTest.php new file mode 100644 index 00000000..94a3a2d8 --- /dev/null +++ b/tests/BlockonomicsTest.php @@ -0,0 +1,114 @@ +api_key = $api_key; + } +} + +class BlockonomicsTest extends TestCase { + + protected function setUp(): void { + parent::setUp(); + wp::setUp(); + $this->blockonomics = new TestableBlockonomics(); + } + + public function testCalculateTotalPaidFiatWithNoTransactions() { + // Mocking wc_get_price_decimals to return 2 decimals + wp::userFunction('wc_get_price_decimals', [ + 'times' => 1, // Ensure this function is called exactly once + 'return' => 2, + ]); + + $transactions = []; + $expectedTotal = 0.0; + $this->assertSame($expectedTotal, $this->blockonomics->calculate_total_paid_fiat($transactions)); + } + + public function testCalculateTotalPaidFiatWithVariousTransactions() { + // Mocking wc_get_price_decimals to return 2 decimals + wp::userFunction('wc_get_price_decimals', [ + 'times' => 1, + 'return' => 2, + ]); + + $transactions = [ + ['paid_fiat' => '10.00'], + ['paid_fiat' => '5.50'], + ['paid_fiat' => '2.50'] + ]; + $expectedTotal = 18.0; + $this->assertEquals($expectedTotal, $this->blockonomics->calculate_total_paid_fiat($transactions)); + } + + public function testFixDisplayingSmallValuesLessThan10000() { + $this->assertEquals("0.000095", $this->blockonomics->fix_displaying_small_values(9500)); + } + + public function testFixDisplayingSmallValuesGreaterThan10000() { + $this->assertEquals(0.0001, $this->blockonomics->fix_displaying_small_values(10000)); + } + + public function testGetCryptoPaymentUriForBTC() { + $crypto = ['uri' => 'bitcoin']; + $address = "bc1qnhuxvspzj28vcdc8e7wxnnwhqdu7pyvdwsw0dy"; + $order_amount = 0.05; + $expectedUri = "bitcoin:bc1qnhuxvspzj28vcdc8e7wxnnwhqdu7pyvdwsw0dy?amount=0.05"; + $this->assertEquals($expectedUri, $this->blockonomics->get_crypto_payment_uri($crypto, $address, $order_amount)); + } + + public function testGetCryptoPaymentUriForBCH() { + $crypto = ['uri' => 'bitcoincash']; + $address = "qr3fmxznghk8h0af7mpj0ay590ev5js72chef5md3w"; + $order_amount = 0.1; + $expectedUri = "bitcoincash:qr3fmxznghk8h0af7mpj0ay590ev5js72chef5md3w?amount=0.1"; + $this->assertEquals($expectedUri, $this->blockonomics->get_crypto_payment_uri($crypto, $address, $order_amount)); + } + + public function testGetSupportedCurrencies() { + $expectedCurrencies = [ + 'btc' => [ + 'code' => 'btc', + 'name' => 'Bitcoin', + 'uri' => 'bitcoin' + ], + 'bch' => [ + 'code' => 'bch', + 'name' => 'Bitcoin Cash', + 'uri' => 'bitcoincash' + ] + ]; + $actualCurrencies = $this->blockonomics->getSupportedCurrencies(); + $this->assertEquals($expectedCurrencies, $actualCurrencies, "The getSupportedCurrencies method did not return the expected array of cryptocurrencies."); + } + + public function testSetHeadersWithEmptyApiKey() { + $reflection = new \ReflectionClass($this->blockonomics); + $method = $reflection->getMethod('set_headers'); + $method->setAccessible(true); // Makes private method accessible + + $result = $method->invokeArgs($this->blockonomics, ['']); + $this->assertEquals('', $result); + } + + public function testSetHeadersWithNonEmptyApiKey() { + $reflection = new \ReflectionClass($this->blockonomics); + $method = $reflection->getMethod('set_headers'); + $method->setAccessible(true); // Makes private method accessible + + $apiKey = "your_api_key"; + $expectedHeader = 'Authorization: Bearer ' . $apiKey; + $result = $method->invokeArgs($this->blockonomics, [$apiKey]); + $this->assertEquals($expectedHeader, $result); + } + + protected function tearDown(): void { + wp::tearDown(); + parent::tearDown(); + } + +} From 27b5ad7eb9066a1a5456116b048574fb115517c6 Mon Sep 17 00:00:00 2001 From: anktd Date: Thu, 6 Jun 2024 18:12:43 +0530 Subject: [PATCH 05/13] add test setup failure test cases --- tests/BlockonomicsTest.php | 160 ++++++++++++++++++++++++++++++++++++- 1 file changed, 159 insertions(+), 1 deletion(-) mode change 100644 => 100755 tests/BlockonomicsTest.php diff --git a/tests/BlockonomicsTest.php b/tests/BlockonomicsTest.php old mode 100644 new mode 100755 index 94a3a2d8..e889308e --- a/tests/BlockonomicsTest.php +++ b/tests/BlockonomicsTest.php @@ -1,6 +1,7 @@ blockonomics = new TestableBlockonomics(); + // $this->blockonomics = new TestableBlockonomics(); + $this->blockonomics = m::mock('TestableBlockonomics')->makePartial(); + // Mock WordPress get_option function + wp::userFunction('get_option', [ + 'return' => function($option_name) { + switch ($option_name) { + case 'blockonomics_bch': + return true; // Assume BCH is enabled + case 'blockonomics_btc': + return true; // Assume BTC is disabled + case 'blockonomics_api_key': + return 'ZJ4PNtTnKqWxeMCQ6smlMBvj3i3KAtt2hwLSGuk9Lyk'; // Dummy API key + case 'blockonomics_callback_secret': + return '2c5a71c1367e23a6b04a20544d0d4a4601c34881'; // Dummy callback secret + default: + return null; + } + } + ]); + // Mock wp_remote_retrieve_response_code and wp_remote_retrieve_body + wp::userFunction('wp_remote_retrieve_response_code', [ + 'return' => function($response) { + return isset($response['response']['code']) ? $response['response']['code'] : null; + } + ]); + wp::userFunction('wp_remote_retrieve_body', [ + 'return' => function($response) { + return json_encode(isset($response['response']['body']) ? $response['response']['body'] : []); + } + ]); } public function testCalculateTotalPaidFiatWithNoTransactions() { @@ -105,6 +135,134 @@ public function testSetHeadersWithNonEmptyApiKey() { $result = $method->invokeArgs($this->blockonomics, [$apiKey]); $this->assertEquals($expectedHeader, $result); } + + private function mockActiveCurrencies(array $cryptos) { + $activeCurrencies = []; + foreach ($cryptos as $crypto) { + switch ($crypto) { + case 'btc': + $activeCurrencies['btc'] = ['code' => 'btc', 'name' => 'Bitcoin', 'uri' => 'bitcoin']; + break; + case 'bch': + $activeCurrencies['bch'] = ['code' => 'bch', 'name' => 'Bitcoin Cash', 'uri' => 'bitcoincash']; + break; + } + } + $this->blockonomics->shouldReceive('getActiveCurrencies') + ->once() + ->andReturn($activeCurrencies); + } + + // Define different mock responses for callback API + private function getMockResponse($type) { + switch ($type) { + case 'incorrect_api_key': + return [ + 'response' => [ + 'code' => 401, + 'message' => 'Unauthorized' + ] + ]; + case 'no_stores_added': + return [ + 'response' => [ + 'code' => 200, + 'message' => 'OK' + ], + 'body' => json_encode([]) // Simulate no stores added + ]; + default: + return [ + 'response' => [ + 'code' => 400, + 'body' => 'Bad Request' + ] + ]; + } + } + + private function mockGetCallbacks(array $cryptos, $responseType){ + $mockedResponse = $this->getMockResponse($responseType); + foreach ($cryptos as $crypto) { + $this->blockonomics->shouldReceive('get_callbacks') + ->with($crypto) + ->andReturn($mockedResponse); + } + } + + // Testing Test Setup functionality + // Case 1: Incorrect API Key is set and only BCH is enabled + public function testBCHWithIncorrectAPIKeySetup() { + // Mock getActiveCurrencies to return only BCH + $this->mockActiveCurrencies(['bch']); + // Use getMockResponse to get the mock response for incorrect API key + $mockedResponse = $this->getMockResponse('incorrect_api_key'); + // Mock the response for get_callbacks to simulate incorrect API key + $this->mockGetCallbacks(['bch'], 'incorrect_api_key'); + // Execute testSetup and capture the results + $result = $this->blockonomics->testSetup(); + // Assert that the error "API Key is incorrect" is returned for BCH + $this->assertEquals(['bch' => 'API Key is incorrect'], $result); + } + + // Case 2: Incorrect API Key is set and only BTC is enabled + public function testBTCWithIncorrectAPIKeySetup() { + // Mock getActiveCurrencies to return only BTC + $this->mockActiveCurrencies(['btc']); + $mockedResponse = $this->getMockResponse('incorrect_api_key'); + $this->mockGetCallbacks(['btc'], 'incorrect_api_key'); + $result = $this->blockonomics->testSetup(); + $this->assertEquals(['btc' => 'API Key is incorrect'], $result); + } + + // Case 3: BTC & BCH are enabled and API key set is incorrect + public function testBTCandBCHWithIncorrectAPIKeySetup() { + // Mock getActiveCurrencies to return both BTC and BCH + $this->mockActiveCurrencies(['btc', 'bch']); + $mockedResponse = $this->getMockResponse('incorrect_api_key'); + $this->mockGetCallbacks(['btc','bch'], 'incorrect_api_key'); + $result = $this->blockonomics->testSetup(); + // Assert that the error "API Key is incorrect" is returned for both BTC and BCH + $this->assertEquals(['btc' => 'API Key is incorrect', 'bch' => 'API Key is incorrect'], $result); + } + + //Case 4: only BCH is enabled, API Key is correct but no xpub is added + public function testBCHWithNoStore() { + // Mock getActiveCurrencies to return only BCH + $this->mockActiveCurrencies(['bch']); + // Use getMockResponse to simulate no stores added with a correct API key + $mockedResponse = $this->getMockResponse('no_stores_added'); + $this->mockGetCallbacks(['bch'], 'no_stores_added'); + // Execute testSetup and capture the results + $result = $this->blockonomics->testSetup(); + // Assert that the error message for no store added is returned for BCH + $this->assertEquals(['bch' => 'Please add a new store on blockonomics website'], $result); + } + + //Case 5: only BTC is enabled, API Key is correct but no xpub is added + public function testBTCWithNoStore() { + // Mock getActiveCurrencies to return only BTC + $this->mockActiveCurrencies(['btc']); + // Use getMockResponse to simulate no stores added with a correct API key + $mockedResponse = $this->getMockResponse('no_stores_added'); + $this->mockGetCallbacks(['btc'], 'no_stores_added'); + // Execute testSetup and capture the results + $result = $this->blockonomics->testSetup(); + // Assert that the error message for no store added is returned for BTC + $this->assertEquals(['btc' => 'Please add a new store on blockonomics website'], $result); + } + + // Case 6: both BTC, BCH enabled , API Key is correct but no xpub added for any of BTC/BCH + public function testBTCandBCHWithNoStore() { + // Mock active currencies for both BTC and BCH + $this->mockActiveCurrencies(['btc', 'bch']); + // Use getMockResponse to simulate no stores added with a correct API key + $mockedResponse = $this->getMockResponse('no_stores_added'); + $this->mockGetCallbacks(['btc', 'bch'], 'no_stores_added'); + $result = $this->blockonomics->testSetup(); + // Assert that the error message for no store added is returned for both BTC and BCH + $this->assertEquals(['btc' => 'Please add a new store on blockonomics website', 'bch' => 'Please add a new store on blockonomics website'], $result); + } protected function tearDown(): void { wp::tearDown(); From 3270bb071c91b7ca97ec11ae23070985345cd807 Mon Sep 17 00:00:00 2001 From: ankit <97018228+anktd@users.noreply.github.com> Date: Thu, 6 Jun 2024 18:31:04 +0530 Subject: [PATCH 06/13] add yaml file for github action workflow --- .github/workflows/main.yml | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..5277cdb9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,50 @@ +name: Run PHPUnit Tests + +on: [push, pull_request] + +jobs: + build: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: wordpress_tests + ports: + - 3306:3306 + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=10s + --health-retries=10 + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP, with Composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: mbstring, xml, curl, pdo_mysql + coverage: pcov + tools: composer:v2 + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Start MySQL + run: sudo /etc/init.d/mysql start + + - name: Prepare WordPress Database + run: | + mysql -e 'CREATE DATABASE wordpress_tests;' -uroot -proot + mysql -e "GRANT ALL PRIVILEGES ON wordpress_tests.* TO 'wp'@'localhost' IDENTIFIED BY 'wp';" -uroot -proot + mysql -e 'FLUSH PRIVILEGES;' -uroot -proot + + - name: Run PHPUnit tests + run: vendor/bin/phpunit + + - name: Check coding standards + run: ./vendor/bin/phpcs From 0869511afc555be1d8842f95f0ba4e1a19bcdde9 Mon Sep 17 00:00:00 2001 From: anktd Date: Thu, 6 Jun 2024 18:41:15 +0530 Subject: [PATCH 07/13] Update PHP version and adjust dependencies for compatibility --- composer.json | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 1e4963a6..6620602c 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "blockonomics/test", "require-dev": { - "phpunit/phpunit": "^9.5", + "phpunit/phpunit": "^8.5 || ^9.5", "10up/wp_mock": "^0.5.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index 65c5710d..87da7b96 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": "60c30868d55781be2f7425f966d07fe5", + "content-hash": "c1da18739cb620c15fb4612c8c7e3b9c", "packages": [], "packages-dev": [ { @@ -224,16 +224,16 @@ }, { "name": "mockery/mockery", - "version": "1.6.11", + "version": "1.6.12", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "81a161d0b135df89951abd52296adf97deb0723d" + "reference": "1f4efdd7d3beafe9807b08156dfcb176d18f1699" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mockery/mockery/zipball/81a161d0b135df89951abd52296adf97deb0723d", - "reference": "81a161d0b135df89951abd52296adf97deb0723d", + "url": "https://api.github.com/repos/mockery/mockery/zipball/1f4efdd7d3beafe9807b08156dfcb176d18f1699", + "reference": "1f4efdd7d3beafe9807b08156dfcb176d18f1699", "shasum": "" }, "require": { @@ -303,7 +303,7 @@ "security": "https://github.com/mockery/mockery/security/advisories", "source": "https://github.com/mockery/mockery" }, - "time": "2024-03-21T18:34:15+00:00" + "time": "2024-05-16T03:13:13+00:00" }, { "name": "myclabs/deep-copy", From 52b48c2935b6121dc349261efde5da1b7a34f789 Mon Sep 17 00:00:00 2001 From: anktd Date: Thu, 6 Jun 2024 18:48:22 +0530 Subject: [PATCH 08/13] Update yaml to adjust dependencies for compatibility --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5277cdb9..4e222448 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,13 +26,13 @@ jobs: - name: Setup PHP, with Composer and extensions uses: shivammathur/setup-php@v2 with: - php-version: '7.4' + php-version: '8.1' # Ensuring PHP 8.1 is used extensions: mbstring, xml, curl, pdo_mysql coverage: pcov tools: composer:v2 - name: Install dependencies - run: composer install --prefer-dist --no-progress --no-suggest + run: composer install --prefer-dist --no-progress - name: Start MySQL run: sudo /etc/init.d/mysql start From 11e5042a55730ac8dfc6caf75a5b6776d72f3e2b Mon Sep 17 00:00:00 2001 From: anktd Date: Thu, 6 Jun 2024 18:51:20 +0530 Subject: [PATCH 09/13] Update steps to prepare wordpress db in yaml --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4e222448..821a8207 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,8 @@ jobs: - name: Prepare WordPress Database run: | mysql -e 'CREATE DATABASE wordpress_tests;' -uroot -proot - mysql -e "GRANT ALL PRIVILEGES ON wordpress_tests.* TO 'wp'@'localhost' IDENTIFIED BY 'wp';" -uroot -proot + mysql -e "CREATE USER 'wp'@'localhost' IDENTIFIED BY 'wp';" -uroot -proot + mysql -e "GRANT ALL PRIVILEGES ON wordpress_tests.* TO 'wp'@'localhost';" -uroot -proot mysql -e 'FLUSH PRIVILEGES;' -uroot -proot - name: Run PHPUnit tests From 86ea0eb832eb16ebf3eaa297f974d46db019897c Mon Sep 17 00:00:00 2001 From: anktd Date: Thu, 6 Jun 2024 18:54:20 +0530 Subject: [PATCH 10/13] Update phpunit run test command in yaml --- .github/workflows/main.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 821a8207..fe01d92c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,7 +45,4 @@ jobs: mysql -e 'FLUSH PRIVILEGES;' -uroot -proot - name: Run PHPUnit tests - run: vendor/bin/phpunit - - - name: Check coding standards - run: ./vendor/bin/phpcs + run: vendor/bin/phpunit tests/ \ No newline at end of file From 6e98e4220ae8e4e2b6743e802a4d9b30e9c87786 Mon Sep 17 00:00:00 2001 From: anktd Date: Wed, 19 Jun 2024 18:35:58 +0530 Subject: [PATCH 11/13] more test cases --- tests/BlockonomicsTest.php | 161 ++++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 3 deletions(-) diff --git a/tests/BlockonomicsTest.php b/tests/BlockonomicsTest.php index e889308e..06ccbc45 100755 --- a/tests/BlockonomicsTest.php +++ b/tests/BlockonomicsTest.php @@ -16,7 +16,7 @@ protected function setUp(): void { parent::setUp(); wp::setUp(); // $this->blockonomics = new TestableBlockonomics(); - $this->blockonomics = m::mock('TestableBlockonomics')->makePartial(); + $this->blockonomics = m::mock(TestableBlockonomics::class, ['ZJ4PNtTnKqWxeMCQ6smlMBvj3i3KAtt2hwLSGuk9Lyk'])->makePartial(); // Mock WordPress get_option function wp::userFunction('get_option', [ 'return' => function($option_name) { @@ -42,7 +42,33 @@ protected function setUp(): void { ]); wp::userFunction('wp_remote_retrieve_body', [ 'return' => function($response) { - return json_encode(isset($response['response']['body']) ? $response['response']['body'] : []); + return isset($response['body']) ? $response['body'] : []; + } + ]); + // Mock WC() function + wp::userFunction('WC', [ + 'return' => function() { + return new class{ + public function api_request_url($endpoint) { + return "https://localhost:8888/wordpress/wc-api/WC_Gateway_Blockonomics/"; + //TODO: look for variations in http cases + } + }; + } + ]); + + // Mock add_query_arg function i.e. appends query arguments to a URL + wp::userFunction('add_query_arg', [ + 'return' => function($args, $url) { + if (!is_array($args)) { + $args = []; + } + return $url . '?' . http_build_query($args); + } + ]); + wp::userFunction('is_wp_error', [ + 'return' => function($thing) { + return ($thing instanceof \WP_Error); } ]); } @@ -169,7 +195,23 @@ private function getMockResponse($type) { 'code' => 200, 'message' => 'OK' ], - 'body' => json_encode([]) // Simulate no stores added + 'body' => json_encode([]) // no stores added + ]; + case 'one_store_different_callback': + return [ + 'response' => [ + 'code' => 200, + 'message' => 'OK' + ], + 'body' => json_encode([['address' => 'zpub6o4sVoUnjZ8qWRtWUFHL9TWKfStSo2rquV6LsHJWNDbrEP5L2CAG849xpXJXzsm4iNTbKGS6Q4gxK6mYQqfd1JCP3KKYco2DBxTrjpywWxt', 'tag' => 't_shirt_store_wordpress', 'callback' => 'http://localhost:8888/wordpress/wc-api/WC_Gateway_Blockonomics/?secret=30d8ea3494a820e37ffb46c801a6cce96cc2023e']]) + ]; + case 'one_store_no_callback': + return [ + 'response' => [ + 'code' => 200, + 'message' => 'OK' + ], + 'body' => json_encode([['address' => 'zpub6o4sVoUnjZ8qWRtWUFHL9TWKfStSo2rquV6LsHJWNDbrEP5L2CAG849xpXJXzsm4iNTbKGS6Q4gxK6mYQqfd1JCP3KKYco2DBxTrjpywWxt', 'tag' => 't_shirt_store_wordpress', 'callback' => '']]) ]; default: return [ @@ -189,6 +231,17 @@ private function mockGetCallbacks(array $cryptos, $responseType){ ->andReturn($mockedResponse); } } + private function mockUpdateCallbackResponse() { + wp::userFunction('wp_remote_post', [ + 'return' => [ + 'response' => [ + 'code' => 200, + 'message' => 'OK' + ], + 'body' => '' + ] + ]); + } // Testing Test Setup functionality // Case 1: Incorrect API Key is set and only BCH is enabled @@ -264,6 +317,108 @@ public function testBTCandBCHWithNoStore() { $this->assertEquals(['btc' => 'Please add a new store on blockonomics website', 'bch' => 'Please add a new store on blockonomics website'], $result); } + // API key is correct, 1 xpub is added and callback url is not set + public function testBTCWithOneStoreNoCallback() { + // Mock active currencies to return only BTC + $this->mockActiveCurrencies(['btc']); + + // Simulate the response where one store is added without any callback URL + $this->blockonomics->shouldReceive('get_callbacks') + ->with('btc') + ->andReturn($this->getMockResponse('one_store_no_callback')); + + // Mock the update callback response + $this->mockUpdateCallbackResponse(); + + // Execute testSetup and capture the results + $result = $this->blockonomics->testSetup(); + + // Assert that no errors are returned + $this->assertFalse($result['btc']); + } + + public function testBCHWithOneStoreNoCallback() { + // Mock active currencies to return only BCH + $this->mockActiveCurrencies(['bch']); + + // Simulate the response where one store is added without any callback URL + $this->blockonomics->shouldReceive('get_callbacks') + ->with('bch') + ->andReturn($this->getMockResponse('one_store_no_callback')); + + // Mock the update callback response + $this->mockUpdateCallbackResponse(); + + // Execute testSetup and capture the results + $result = $this->blockonomics->testSetup(); + + // Assert that no errors are returned + $this->assertFalse($result['bch']); + } + + public function testBTCandBCHWithOneStoreNoCallback() { + // Mock active currencies to return only BTC + $this->mockActiveCurrencies(['btc','bch']); + + // Simulate the response where one store is added without any callback URL + $this->blockonomics->shouldReceive('get_callbacks') + ->with('btc') + ->andReturn($this->getMockResponse('one_store_no_callback')); + + $this->blockonomics->shouldReceive('get_callbacks') + ->with('bch') + ->andReturn($this->getMockResponse('one_store_no_callback')); + + // Mock the update callback response + $this->mockUpdateCallbackResponse(); + + // Execute testSetup and capture the results + $result = $this->blockonomics->testSetup(); + + // Assert that no errors are returned + $this->assertFalse($result['btc']); + $this->assertFalse($result['bch']); + } + + public function testBTCWithOneStoreDifferentCallback() { + // Mock active currencies to return only BTC + $this->mockActiveCurrencies(['btc']); + + // Simulate the response where one store is added with a different callback URL + $this->blockonomics->shouldReceive('get_callbacks') + ->with('btc') + ->andReturn($this->getMockResponse('one_store_different_callback')); + + // Mock the update callback response to capture its input parameters + $callbackUrl = null; + $crypto = null; + $xpub = null; + + $this->blockonomics->shouldReceive('update_callback') + ->with(m::on(function($arg) use (&$callbackUrl) { + $callbackUrl = $arg; + return true; + }), m::on(function($arg) use (&$crypto) { + $crypto = $arg; + return true; + }), m::on(function($arg) use (&$xpub) { + $xpub = $arg; + return true; + })) + ->andReturn((object)[ + 'response_code' => 200, + 'response_message' => 'OK' + ]); + + // Execute testSetup and capture the results + $result = $this->blockonomics->testSetup(); + error_log("Result from testSetup: " . print_r($result, true)); + + // Assert that the expected error message is returned + $this->assertEquals('Please add a new store on blockonomics website', $result['btc']); + + } + protected function tearDown(): void { wp::tearDown(); parent::tearDown(); From 133b184cb2c38441565e0cbe4a31c99efb23fd7c Mon Sep 17 00:00:00 2001 From: anktd Date: Sat, 22 Jun 2024 07:52:24 +0530 Subject: [PATCH 12/13] tests for callback functionality) --- tests/BlockonomicsTest.php | 200 +++++++++++++++++++++++++++++++------ 1 file changed, 167 insertions(+), 33 deletions(-) diff --git a/tests/BlockonomicsTest.php b/tests/BlockonomicsTest.php index 06ccbc45..6c5a0c79 100755 --- a/tests/BlockonomicsTest.php +++ b/tests/BlockonomicsTest.php @@ -380,43 +380,177 @@ public function testBTCandBCHWithOneStoreNoCallback() { $this->assertFalse($result['bch']); } - public function testBTCWithOneStoreDifferentCallback() { - // Mock active currencies to return only BTC - $this->mockActiveCurrencies(['btc']); + // Tests focused on Callbacks functionality + + public function testUpdateCallbackForBTC() { + $callbackUrl = 'https://example.com/callback'; + $crypto = 'btc'; + $xpub = 'xpub12345'; + $expectedUrl = Blockonomics::SET_CALLBACK_URL; + $expectedBody = json_encode(['callback' => $callbackUrl, 'xpub' => $xpub]); + wp::userFunction('wp_remote_post', [ + 'return' => [ + 'response' => [ + 'code' => 200, + 'message' => 'OK' + ], + 'body' => json_encode(['status' => 'success']) + ] + ]); + $result = $this->blockonomics->update_callback($callbackUrl, $crypto, $xpub); + $this->assertEquals(200, $result->response_code); + } - // Simulate the response where one store is added with a different callback URL - $this->blockonomics->shouldReceive('get_callbacks') - ->with('btc') - ->andReturn($this->getMockResponse('one_store_different_callback')); - - // Mock the update callback response to capture its input parameters - $callbackUrl = null; - $crypto = null; - $xpub = null; - - $this->blockonomics->shouldReceive('update_callback') - ->with(m::on(function($arg) use (&$callbackUrl) { - $callbackUrl = $arg; - return true; - }), m::on(function($arg) use (&$crypto) { - $crypto = $arg; - return true; - }), m::on(function($arg) use (&$xpub) { - $xpub = $arg; - return true; - })) - ->andReturn((object)[ - 'response_code' => 200, - 'response_message' => 'OK' - ]); + public function testUpdateCallbackForBCH() { + $callbackUrl = 'https://example.com/callback'; + $crypto = 'bch'; + $xpub = 'xpub12345'; + $expectedUrl = Blockonomics::BCH_SET_CALLBACK_URL; + $expectedBody = json_encode(['callback' => $callbackUrl, 'xpub' => $xpub]); + wp::userFunction('wp_remote_post', [ + 'return' => [ + 'response' => [ + 'code' => 200, + 'message' => 'OK' + ], + 'body' => json_encode(['status' => 'success']) + ] + ]); + $result = $this->blockonomics->update_callback($callbackUrl, $crypto, $xpub); + $this->assertEquals(200, $result->response_code); + } - // Execute testSetup and capture the results - $result = $this->blockonomics->testSetup(); - error_log("Result from testSetup: " . print_r($result, true)); + public function testUpdateCallbackWithInvalidResponse() { + $callbackUrl = 'https://example.com/callback'; + $crypto = 'btc'; + $xpub = 'xpub12345'; + $expectedUrl = Blockonomics::SET_CALLBACK_URL; + $expectedBody = json_encode(['callback' => $callbackUrl, 'xpub' => $xpub]); + wp::userFunction('wp_remote_post', [ + 'return' => [ + 'response' => [ + 'code' => 500, + 'message' => 'Internal Server Error' + ], + 'body' => '' + ] + ]); + $result = $this->blockonomics->update_callback($callbackUrl, $crypto, $xpub); + $this->assertEquals(500, $result->response_code); + } + + // public function testExamineServerCallbackUrls() { + // $callbackSecret = 'secret123'; + // $apiUrl = 'https://example.com/wc-api/WC_Gateway_Blockonomics'; + // $wordpressCallbackUrl = $apiUrl . '?secret=' . $callbackSecret; + // $responseBody = [ + // (object) ['callback' => '', 'address' => 'xpub1'], + // (object) ['callback' => $wordpressCallbackUrl, 'address' => 'xpub2'], + // (object) ['callback' => 'https://otherurl.com', 'address' => 'xpub3'] + // ]; + // $crypto = 'btc'; + // wp::userFunction('get_option', [ + // 'args' => ['blockonomics_callback_secret'], + // 'return' => $callbackSecret, + // ]); + // wp::userFunction('WC', [ + // 'return' => (object)['api_request_url' => function() use ($apiUrl) { + // return $apiUrl; + // }] + // ]); + // wp::userFunction('add_query_arg', [ + // 'args' => ['secret', $callbackSecret, $apiUrl], + // 'return' => $wordpressCallbackUrl, + // ]); + // wp::userFunction('wp_remote_retrieve_body', [ + // 'args' => [Mockery::type('array')], + // 'return' => json_encode($responseBody), + // ]); + // $decodedResponseBody = json_decode(json_encode($responseBody)); + // $result = $this->blockonomics->examine_server_callback_urls($decodedResponseBody, $crypto); + // $this->assertEquals('', $result); + // } + + // public function testExamineServerCallbackUrlsWithPartialMatch() { + // $callbackSecret = 'secret123'; + // $apiUrl = 'https://example.com/wc-api/WC_Gateway_Blockonomics'; + // $wordpressCallbackUrl = $apiUrl . '?secret=' . $callbackSecret; + // $responseBody = [ + // (object) ['callback' => 'https://example.com/wc-api/WC_Gateway_Blockonomics?secret=oldsecret', 'address' => 'xpub1'], + // (object) ['callback' => 'https://example.com/wc-api/WC_Gateway_Blockonomics', 'address' => 'xpub2'] // Ensure partial match + // ]; + // $crypto = 'btc'; + // wp::userFunction('get_option', [ + // 'args' => ['blockonomics_callback_secret'], + // 'return' => $callbackSecret, + // ]); + // wp::userFunction('WC', [ + // 'return' => (object)['api_request_url' => function() use ($apiUrl) { + // return $apiUrl; + // }] + // ]); + // wp::userFunction('add_query_arg', [ + // 'args' => ['secret', $callbackSecret, $apiUrl], + // 'return' => $wordpressCallbackUrl, + // ]); + // $result = $this->blockonomics->examine_server_callback_urls($responseBody, $crypto); + // $this->assertEquals('', $result); + // } + + public function testExamineServerCallbackUrlsWithNoMatch() { + $callbackSecret = 'secret123'; + $apiUrl = 'https://example.com/wc-api/WC_Gateway_Blockonomics'; + $wordpressCallbackUrl = $apiUrl . '?secret=' . $callbackSecret; + $responseBody = [ + (object) ['callback' => 'https://otherurl.com', 'address' => 'xpub1'], + (object) ['callback' => 'https://anotherurl.com', 'address' => 'xpub2'] + ]; + $crypto = 'btc'; + + wp::userFunction('get_option', [ + 'args' => ['blockonomics_callback_secret'], + 'return' => $callbackSecret, + ]); + + wp::userFunction('WC', [ + 'return' => (object)['api_request_url' => function() use ($apiUrl) { + return $apiUrl; + }] + ]); + + wp::userFunction('add_query_arg', [ + 'args' => ['secret', $callbackSecret, $apiUrl], + 'return' => $wordpressCallbackUrl, + ]); + + $result = $this->blockonomics->examine_server_callback_urls($responseBody, $crypto); + + $this->assertEquals('Please add a new store on blockonomics website', $result); + } + + public function testCheckCallbackUrlsOrSetOne() { + $crypto = 'btc'; + $response = Mockery::mock('response'); + $this->blockonomics->shouldReceive('check_get_callbacks_response_code') + ->with($response, $crypto) + ->andReturn(''); + $this->blockonomics->shouldReceive('check_get_callbacks_response_body') + ->with($response, $crypto) + ->andReturn('error'); + $result = $this->blockonomics->check_callback_urls_or_set_one($crypto, $response); + $this->assertEquals('error', $result); + } + + public function testCheckCallbackUrlsOrSetOneWithError() { + $crypto = 'btc'; + $response = Mockery::mock(); + $this->blockonomics->shouldReceive('check_get_callbacks_response_code') + ->with($response, $crypto) + ->andReturn('error_code'); - // Assert that the expected error message is returned - $this->assertEquals('Please add a new store on blockonomics website', $result['btc']); + $result = $this->blockonomics->check_callback_urls_or_set_one($crypto, $response); + $this->assertEquals('error_code', $result); } protected function tearDown(): void { From 2c2a34f0b5e6d65d4f21f289773f253b7996fcf2 Mon Sep 17 00:00:00 2001 From: anktd Date: Mon, 1 Jul 2024 17:12:48 +0530 Subject: [PATCH 13/13] add callback url testing for no match case --- tests/BlockonomicsTest.php | 93 +++++++++++++++----------------------- 1 file changed, 36 insertions(+), 57 deletions(-) diff --git a/tests/BlockonomicsTest.php b/tests/BlockonomicsTest.php index 6c5a0c79..287a7c50 100755 --- a/tests/BlockonomicsTest.php +++ b/tests/BlockonomicsTest.php @@ -439,63 +439,42 @@ public function testUpdateCallbackWithInvalidResponse() { $this->assertEquals(500, $result->response_code); } - // public function testExamineServerCallbackUrls() { - // $callbackSecret = 'secret123'; - // $apiUrl = 'https://example.com/wc-api/WC_Gateway_Blockonomics'; - // $wordpressCallbackUrl = $apiUrl . '?secret=' . $callbackSecret; - // $responseBody = [ - // (object) ['callback' => '', 'address' => 'xpub1'], - // (object) ['callback' => $wordpressCallbackUrl, 'address' => 'xpub2'], - // (object) ['callback' => 'https://otherurl.com', 'address' => 'xpub3'] - // ]; - // $crypto = 'btc'; - // wp::userFunction('get_option', [ - // 'args' => ['blockonomics_callback_secret'], - // 'return' => $callbackSecret, - // ]); - // wp::userFunction('WC', [ - // 'return' => (object)['api_request_url' => function() use ($apiUrl) { - // return $apiUrl; - // }] - // ]); - // wp::userFunction('add_query_arg', [ - // 'args' => ['secret', $callbackSecret, $apiUrl], - // 'return' => $wordpressCallbackUrl, - // ]); - // wp::userFunction('wp_remote_retrieve_body', [ - // 'args' => [Mockery::type('array')], - // 'return' => json_encode($responseBody), - // ]); - // $decodedResponseBody = json_decode(json_encode($responseBody)); - // $result = $this->blockonomics->examine_server_callback_urls($decodedResponseBody, $crypto); - // $this->assertEquals('', $result); - // } - - // public function testExamineServerCallbackUrlsWithPartialMatch() { - // $callbackSecret = 'secret123'; - // $apiUrl = 'https://example.com/wc-api/WC_Gateway_Blockonomics'; - // $wordpressCallbackUrl = $apiUrl . '?secret=' . $callbackSecret; - // $responseBody = [ - // (object) ['callback' => 'https://example.com/wc-api/WC_Gateway_Blockonomics?secret=oldsecret', 'address' => 'xpub1'], - // (object) ['callback' => 'https://example.com/wc-api/WC_Gateway_Blockonomics', 'address' => 'xpub2'] // Ensure partial match - // ]; - // $crypto = 'btc'; - // wp::userFunction('get_option', [ - // 'args' => ['blockonomics_callback_secret'], - // 'return' => $callbackSecret, - // ]); - // wp::userFunction('WC', [ - // 'return' => (object)['api_request_url' => function() use ($apiUrl) { - // return $apiUrl; - // }] - // ]); - // wp::userFunction('add_query_arg', [ - // 'args' => ['secret', $callbackSecret, $apiUrl], - // 'return' => $wordpressCallbackUrl, - // ]); - // $result = $this->blockonomics->examine_server_callback_urls($responseBody, $crypto); - // $this->assertEquals('', $result); - // } + public function testExamineServerCallbackUrlsNoMatchNoEmptyCallback() { + $callbackSecret = 'secret123'; + $apiUrl = 'https://example.com/wc-api/WC_Gateway_Blockonomics'; + $wordpressCallbackUrl = $apiUrl . '?secret=' . $callbackSecret; + $responseBody = [ + (object) ['callback' => 'https://anotherurl.com', 'address' => 'xpub1'], + (object) ['callback' => 'https://otherurl.com', 'address' => 'xpub2'] + ]; + + $crypto = 'btc'; + + // Mock WordPress get_option function + wp::userFunction('get_option', [ + 'args' => ['blockonomics_callback_secret'], + 'return' => $callbackSecret, + ]); + + // Mock WordPress WC function + wp::userFunction('WC', [ + 'return' => (object)['api_request_url' => function() use ($apiUrl) { + return $apiUrl; + }] + ]); + + // Mock WordPress add_query_arg function + wp::userFunction('add_query_arg', [ + 'args' => ['secret', $callbackSecret, $apiUrl], + 'return' => $wordpressCallbackUrl, + ]); + + // Directly call the examine_server_callback_urls function + $result = $this->blockonomics->examine_server_callback_urls($responseBody, $crypto); + + // Assert the expected error + $this->assertEquals('Please add a new store on blockonomics website', $result); + } public function testExamineServerCallbackUrlsWithNoMatch() { $callbackSecret = 'secret123';