-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,043 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,43 @@ | ||
assets/etc/defuse.txt | ||
assets/etc/secret.txt | ||
logs/debug.log | ||
logs/error.log | ||
# Composer | ||
vendor | ||
vendor/* | ||
.idea | ||
.idea/* | ||
/composer.phar | ||
composer.lock | ||
|
||
# Editors | ||
project.xml | ||
project.properties | ||
/nbproject/private/ | ||
.buildpath | ||
.project | ||
.settings* | ||
.idea | ||
.vscode | ||
*.sublime-project | ||
*.sublime-workspace | ||
.sublimelinterrc | ||
|
||
# Grunt | ||
/node_modules/ | ||
none | ||
|
||
# Sass | ||
.sass-cache/ | ||
|
||
# OS X metadata | ||
.DS_Store | ||
|
||
# Windows junk | ||
Thumbs.db | ||
|
||
# Tests | ||
/coverage | ||
/tests/bin/tmp | ||
phpcs.xml | ||
phpunit.xml | ||
.phpunit.result.cache | ||
|
||
# DLM | ||
assets/etc/defuse.txt | ||
assets/etc/secret.txt | ||
logs/debug.log | ||
logs/error.log |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<phpunit | ||
bootstrap="tests/bootstrap.php" | ||
backupGlobals="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
> | ||
bootstrap="tests/unit/bootstrap.php" | ||
backupGlobals="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory prefix="test-" suffix=".php">./tests/</directory> | ||
<testsuite name="DigitalLicenseManager"> | ||
<directory suffix=".php">./tests/unit</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> | ||
|
||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
/** | ||
* Class WP_UnitTestCase | ||
* | ||
* @package WooCommerce\Payments\Tests | ||
*/ | ||
|
||
/** | ||
* This stub assists IDE in recognizing PHPUnit tests. | ||
* | ||
* Class WP_UnitTestCase | ||
*/ | ||
class WP_UnitTestCase extends \Yoast\PHPUnitPolyfills\TestCases\TestCase { | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/** | ||
* PHPUnit bootstrap file | ||
* | ||
* @package WooCommerce\Subscriptions | ||
*/ | ||
|
||
$_tests_dir = getenv( 'WP_TESTS_DIR' ); | ||
|
||
if ( ! $_tests_dir ) { | ||
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; | ||
} | ||
|
||
if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) { | ||
echo "Could not find $_tests_dir/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
exit( 1 ); | ||
} | ||
|
||
if ( PHP_VERSION_ID >= 80000 && file_exists( $_tests_dir . '/includes/phpunit7/MockObject' ) ) { | ||
// WP Core test library includes patches for PHPUnit 7 to make it compatible with PHP8. | ||
require_once $_tests_dir . '/includes/phpunit7/MockObject/Builder/NamespaceMatch.php'; | ||
require_once $_tests_dir . '/includes/phpunit7/MockObject/Builder/ParametersMatch.php'; | ||
require_once $_tests_dir . '/includes/phpunit7/MockObject/InvocationMocker.php'; | ||
require_once $_tests_dir . '/includes/phpunit7/MockObject/MockMethod.php'; | ||
} | ||
|
||
|
||
// Give access to tests_add_filter() function. | ||
require_once $_tests_dir . '/includes/functions.php'; | ||
|
||
/** | ||
* Manually load the plugin being tested. | ||
*/ | ||
function _manually_load_plugin() { | ||
|
||
$_plugin_dir = dirname( __FILE__ ) . '/../../'; | ||
|
||
if ( ! function_exists( 'activate_plugin' ) ) { | ||
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | ||
} | ||
|
||
require_once dirname( __FILE__ ) . '/helpers/class-dlm-helper-settings.php'; | ||
DLM_Helper_Settings::setDefaults(); | ||
|
||
tests_add_filter( 'dlm_mock_is_plugin_active', '__return_true' ); | ||
|
||
// Required files for the plugin | ||
$required = [ | ||
realpath( $_plugin_dir . '..' ) . '/woocommerce/woocommerce.php', | ||
]; | ||
foreach ( $required as $item ) { | ||
if ( file_exists( $item ) ) { | ||
echo 'Loaded: '.$item . PHP_EOL; | ||
require_once $item; | ||
} else { | ||
echo "Could not find " . plugin_basename( $item ) . " plugin which is required for unit tests."; | ||
exit( 1 ); | ||
} | ||
} | ||
|
||
// Set a default currency to be used for the multi-currency tests because the default | ||
// is not loaded even though it's set during the tests setup. | ||
update_option( 'woocommerce_currency', 'USD' ); | ||
require $_plugin_dir . '/digital-license-manager.php'; | ||
|
||
IdeoLogix\DigitalLicenseManager\Setup::install( false ); | ||
|
||
} | ||
|
||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); | ||
|
||
// Need those polyfills to run tests in CI. | ||
require_once dirname( __FILE__ ) . '/../../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php'; | ||
|
||
// Start up the WP testing environment. | ||
require $_tests_dir . '/includes/bootstrap.php'; | ||
|
||
// We use outdated PHPUnit version, which emits deprecation errors in PHP 7.4 (deprecated reflection APIs). | ||
if ( defined( 'PHP_VERSION_ID' ) && PHP_VERSION_ID >= 70400 ) { | ||
error_reporting( error_reporting() ^ E_DEPRECATED ); // phpcs:ignore | ||
} |
Oops, something went wrong.