diff --git a/composer.json b/composer.json index 99305b38..3507487c 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "phpunit/phpunit": "^4.8", "squizlabs/php_codesniffer": "*", "wp-coding-standards/wpcs": "^0.14", - "exussum12/coverage-checker": "^0.8.0" + "exussum12/coverage-checker": "^0.8.0", + "10up/wp_mock": "0.2.0" }, "scripts": { "test": "phpunit", diff --git a/composer.lock b/composer.lock index 42a27e42..6647b851 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": "b30205d17edce06405f21b2931b20083", + "content-hash": "24d1264df3d154fd3666ad41b7f5c8b0", "packages": [ { "name": "ebanx/benjamin", @@ -50,6 +50,89 @@ } ], "packages-dev": [ + { + "name": "10up/wp_mock", + "version": "0.2.0", + "source": { + "type": "git", + "url": "https://github.com/10up/wp_mock.git", + "reference": "507e59027e9b0d86eba9b74420962a72c4c2ec9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/10up/wp_mock/zipball/507e59027e9b0d86eba9b74420962a72c4c2ec9e", + "reference": "507e59027e9b0d86eba9b74420962a72c4c2ec9e", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "~2.0.3", + "mockery/mockery": "^0.9.5", + "php": ">=5.6", + "phpunit/phpunit": ">=4.3" + }, + "conflict": { + "phpunit/phpunit": ">=6.0" + }, + "require-dev": { + "behat/behat": "^3.0" + }, + "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+" + ], + "description": "A mocking library to take the pain out of unit testing for WordPress", + "time": "2017-07-19T03:10:11+00:00" + }, + { + "name": "antecedent/patchwork", + "version": "2.0.9", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "cab3be4865e47f1dc447715e76c7b616e48b005d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/cab3be4865e47f1dc447715e76c7b616e48b005d", + "reference": "cab3be4865e47f1dc447715e76c7b616e48b005d", + "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": "2017-08-01T11:52:57+00:00" + }, { "name": "dealerdirect/phpcodesniffer-composer-installer", "version": "v0.4.4", @@ -218,6 +301,122 @@ "description": "Allows checking the code coverage of a single pull request", "time": "2017-11-03T09:29:46+00:00" }, + { + "name": "hamcrest/hamcrest-php", + "version": "1.2.x-dev", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "26968e9810ff0d1aa48f6d67a862559d92a51884" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/26968e9810ff0d1aa48f6d67a862559d92a51884", + "reference": "26968e9810ff0d1aa48f6d67a862559d92a51884", + "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": "1.2-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ], + "files": [ + "hamcrest/Hamcrest.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "time": "2018-02-19T09:04:07+00:00" + }, + { + "name": "mockery/mockery", + "version": "0.9.x-dev", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "be9bf28d8e57d67883cba9fcadfcff8caab667f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/be9bf28d8e57d67883cba9fcadfcff8caab667f8", + "reference": "be9bf28d8e57d67883cba9fcadfcff8caab667f8", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~1.1", + "lib-pcre": ">=7.0", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9.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 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.", + "homepage": "http://github.com/padraic/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2019-02-12T16:07:13+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", @@ -807,6 +1006,7 @@ "mock", "xunit" ], + "abandoned": true, "time": "2015-10-02T06:51:40+00:00" }, { diff --git a/tests/unit/bootstrap.php b/tests/unit/bootstrap.php index e6ae327d..4bf0273f 100644 --- a/tests/unit/bootstrap.php +++ b/tests/unit/bootstrap.php @@ -4,8 +4,10 @@ define('WC_EBANX_VENDOR_DIR', realpath('.') . '/vendor/'); define('IS_TEST', true); + require __DIR__ . '/includes/wc_class.php'; -require __DIR__ . '/includes/wc_function.php'; +//require __DIR__ . '/includes/wc_function.php'; +require WC_EBANX_VENDOR_DIR . '/autoload.php'; require_once realpath('.') . '/gateways/class-wc-ebanx-global-gateway.php'; diff --git a/tests/unit/includes/wc_function.php b/tests/unit/includes/wc_function.php deleted file mode 100644 index ec74aa75..00000000 --- a/tests/unit/includes/wc_function.php +++ /dev/null @@ -1,21 +0,0 @@ - ['BRL'] + ]); + \WP_Mock::userFunction( 'get_plugins', array( + 'return_in_order' => array([['Version' => '0.0.1', 'Name' => 'Mock']]) + )); + $config = new WC_EBANX_Global_Gateway(); $plugin_check = WC_EBANX_Helper::plugin_check($config); $this->assertPluginCheck($plugin_check);