woocommerce/plugins/woocommerce-blocks/tests/bootstrap.php

60 lines
1.7 KiB
PHP
Raw Normal View History

<?php
Add PHP 8.1/8.2 to unit testing matrix (https://github.com/woocommerce/woocommerce-blocks/pull/8757) * Added PHP 8.1 to unit testing matrix * Refactor unit testing to match Gutenberg repo 🤞 * Removed Gutenberg reference from debug information * Updated image running phpunit binary * Reverted image running phpunit binary * Remove composer platform override * Bump @wordpress/env and include phpunit * Update phpunit and tests * Change prefix * Try admin context when install wc * try wc install * adjust phpunit config file * Updated phpunit.xml.dist, composer.json and package.json * Added PHP 8.1 to unit testing matrix * Refactor unit testing to match Gutenberg repo 🤞 * Removed Gutenberg reference from debug information * Updated image running phpunit binary * Reverted image running phpunit binary * Remove composer platform override * Bump @wordpress/env and include phpunit * Update phpunit and tests * Change prefix * Try admin context when install wc * try wc install * adjust phpunit config file * Updated phpunit.xml.dist, composer.json and package.json * Revert install changes * updated npm packages * updated composer lock * updated check assets flow * Updated check assets flow. Yaml file auto formatted. * Updated check assets flow. * Attempt at fixing E2E * Reverted setup permissions step * Add logging information to E2E * Reverted E2E test flow * test playwright perms fix * test e2e perms fix * test e2e perms fix * test e2e perms fix * test e2e perms fix * languages update & debug * languages update & debug * revert * force "@wordpress/env": "^4.9.0" on E2E * update package lock * update package lock --------- Co-authored-by: Mike Jolley <mike.jolley@me.com> Co-authored-by: Niels Lange <info@nielslange.de>
2023-04-21 11:07:37 +00:00
/**
* PHPUnit bootstrap file
*
* @package WooCommerce Blocks
*/
namespace Automattic\WooCommerce\Blocks\Tests;
// Require composer dependencies.
require_once dirname( __DIR__ ) . '/vendor/autoload.php';
// Determine the tests directory (from a WP dev checkout).
// Try the WP_TESTS_DIR environment variable first.
$_wc_tests_framework_dir = dirname( dirname( __DIR__ ) ) . '/woocommerce/tests/legacy';
Add PHP 8.1/8.2 to unit testing matrix (https://github.com/woocommerce/woocommerce-blocks/pull/8757) * Added PHP 8.1 to unit testing matrix * Refactor unit testing to match Gutenberg repo 🤞 * Removed Gutenberg reference from debug information * Updated image running phpunit binary * Reverted image running phpunit binary * Remove composer platform override * Bump @wordpress/env and include phpunit * Update phpunit and tests * Change prefix * Try admin context when install wc * try wc install * adjust phpunit config file * Updated phpunit.xml.dist, composer.json and package.json * Added PHP 8.1 to unit testing matrix * Refactor unit testing to match Gutenberg repo 🤞 * Removed Gutenberg reference from debug information * Updated image running phpunit binary * Reverted image running phpunit binary * Remove composer platform override * Bump @wordpress/env and include phpunit * Update phpunit and tests * Change prefix * Try admin context when install wc * try wc install * adjust phpunit config file * Updated phpunit.xml.dist, composer.json and package.json * Revert install changes * updated npm packages * updated composer lock * updated check assets flow * Updated check assets flow. Yaml file auto formatted. * Updated check assets flow. * Attempt at fixing E2E * Reverted setup permissions step * Add logging information to E2E * Reverted E2E test flow * test playwright perms fix * test e2e perms fix * test e2e perms fix * test e2e perms fix * test e2e perms fix * languages update & debug * languages update & debug * revert * force "@wordpress/env": "^4.9.0" on E2E * update package lock * update package lock --------- Co-authored-by: Mike Jolley <mike.jolley@me.com> Co-authored-by: Niels Lange <info@nielslange.de>
2023-04-21 11:07:37 +00:00
$_tests_dir = getenv( 'WP_TESTS_DIR' );
// Next, try the WP_PHPUNIT composer package.
if ( ! $_tests_dir ) {
$_tests_dir = getenv( 'WP_PHPUNIT__DIR' );
}
// See if we're installed inside an existing WP dev instance.
if ( ! $_tests_dir ) {
$_try_tests_dir = __DIR__ . '/../../../../../tests/phpunit';
if ( file_exists( $_try_tests_dir . '/includes/functions.php' ) ) {
$_tests_dir = $_try_tests_dir;
}
}
// Fallback.
if ( ! $_tests_dir ) {
$_tests_dir = '/tmp/wordpress-tests-lib';
}
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
/**
* Manually load the plugin being tested.
*/
function manually_load_plugins() {
require dirname( dirname( __DIR__ ) ) . '/woocommerce/woocommerce.php';
require dirname( __DIR__ ) . '/woocommerce-gutenberg-products-block.php';
}
tests_add_filter( 'muplugins_loaded', __NAMESPACE__ . '\\manually_load_plugins' );
Update relevant files due to L2->L0 policy change for minimum required versions. (https://github.com/woocommerce/woocommerce-blocks/pull/4484) * update README files with version requirements * update phpcs config * update default environment for tests locally * update workflows to only test against versions matching new policy * update plugin header for new version policy * restore older WP version support in E2E tests and PHPCS I realized that we might still want to test against L2 WP versions in our E2E tests until those tests can be moved to WC core. While the feature plugin is L0, we still need to support L2 for existing features that are already surfaced in the WooCommerce plugin package. Also with PHPCS if there are fixes to older things in the codebase, we will need to preserve the usage of L2 friendly (back-compat) code. * add detection of Woo Core version to bootstrap * update version used in phpunit tests * add links to version policy update post * restore 5.5.1 for Woo Core version Getting errors with 5.5.2 - not sure what's going on but might be the tag isn't available as expected for 5.5.2 maybe? * switch to hardcoded version header reference PHPUNIT was tripping on this for some reason. * remove older WP version e2e test workflows * fix phpunit tests for new woo test suite Woo Core now uses a container and has some mocks that are used in some legacy test helpers. * remove explicit set WOO_VERSION for phpunit tests. This should default to latest for the GH workflow runs. * Update release PR template. Add some explicit instructions around updating required WP and WC versions at time of release. * use latest WOO_VERSION in .env * some improvements to reduce the things needing updated * remove extraneous code * Add some more checklist items to release PR templates * remove unnecessary conditional * remove is-dismissible css classes * Improve clarity of error messaging * Update README.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * remove checklist items about versions for patch releases Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-07-29 14:52:34 +00:00
/**
* Manually install plugins being tested.
Update relevant files due to L2->L0 policy change for minimum required versions. (https://github.com/woocommerce/woocommerce-blocks/pull/4484) * update README files with version requirements * update phpcs config * update default environment for tests locally * update workflows to only test against versions matching new policy * update plugin header for new version policy * restore older WP version support in E2E tests and PHPCS I realized that we might still want to test against L2 WP versions in our E2E tests until those tests can be moved to WC core. While the feature plugin is L0, we still need to support L2 for existing features that are already surfaced in the WooCommerce plugin package. Also with PHPCS if there are fixes to older things in the codebase, we will need to preserve the usage of L2 friendly (back-compat) code. * add detection of Woo Core version to bootstrap * update version used in phpunit tests * add links to version policy update post * restore 5.5.1 for Woo Core version Getting errors with 5.5.2 - not sure what's going on but might be the tag isn't available as expected for 5.5.2 maybe? * switch to hardcoded version header reference PHPUNIT was tripping on this for some reason. * remove older WP version e2e test workflows * fix phpunit tests for new woo test suite Woo Core now uses a container and has some mocks that are used in some legacy test helpers. * remove explicit set WOO_VERSION for phpunit tests. This should default to latest for the GH workflow runs. * Update release PR template. Add some explicit instructions around updating required WP and WC versions at time of release. * use latest WOO_VERSION in .env * some improvements to reduce the things needing updated * remove extraneous code * Add some more checklist items to release PR templates * remove unnecessary conditional * remove is-dismissible css classes * Improve clarity of error messaging * Update README.md Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com> * remove checklist items about versions for patch releases Co-authored-by: Albert Juhé Lluveras <contact@albertjuhe.com>
2021-07-29 14:52:34 +00:00
*/
function manually_install_plugins() {
Add PHP 8.1/8.2 to unit testing matrix (https://github.com/woocommerce/woocommerce-blocks/pull/8757) * Added PHP 8.1 to unit testing matrix * Refactor unit testing to match Gutenberg repo 🤞 * Removed Gutenberg reference from debug information * Updated image running phpunit binary * Reverted image running phpunit binary * Remove composer platform override * Bump @wordpress/env and include phpunit * Update phpunit and tests * Change prefix * Try admin context when install wc * try wc install * adjust phpunit config file * Updated phpunit.xml.dist, composer.json and package.json * Added PHP 8.1 to unit testing matrix * Refactor unit testing to match Gutenberg repo 🤞 * Removed Gutenberg reference from debug information * Updated image running phpunit binary * Reverted image running phpunit binary * Remove composer platform override * Bump @wordpress/env and include phpunit * Update phpunit and tests * Change prefix * Try admin context when install wc * try wc install * adjust phpunit config file * Updated phpunit.xml.dist, composer.json and package.json * Revert install changes * updated npm packages * updated composer lock * updated check assets flow * Updated check assets flow. Yaml file auto formatted. * Updated check assets flow. * Attempt at fixing E2E * Reverted setup permissions step * Add logging information to E2E * Reverted E2E test flow * test playwright perms fix * test e2e perms fix * test e2e perms fix * test e2e perms fix * test e2e perms fix * languages update & debug * languages update & debug * revert * force "@wordpress/env": "^4.9.0" on E2E * update package lock * update package lock --------- Co-authored-by: Mike Jolley <mike.jolley@me.com> Co-authored-by: Niels Lange <info@nielslange.de>
2023-04-21 11:07:37 +00:00
\WC_Install::install();
\Automattic\WooCommerce\Blocks\Package::container()->get( \Automattic\WooCommerce\Blocks\Installer::class )->maybe_create_tables();
}
Add PHP 8.1/8.2 to unit testing matrix (https://github.com/woocommerce/woocommerce-blocks/pull/8757) * Added PHP 8.1 to unit testing matrix * Refactor unit testing to match Gutenberg repo 🤞 * Removed Gutenberg reference from debug information * Updated image running phpunit binary * Reverted image running phpunit binary * Remove composer platform override * Bump @wordpress/env and include phpunit * Update phpunit and tests * Change prefix * Try admin context when install wc * try wc install * adjust phpunit config file * Updated phpunit.xml.dist, composer.json and package.json * Added PHP 8.1 to unit testing matrix * Refactor unit testing to match Gutenberg repo 🤞 * Removed Gutenberg reference from debug information * Updated image running phpunit binary * Reverted image running phpunit binary * Remove composer platform override * Bump @wordpress/env and include phpunit * Update phpunit and tests * Change prefix * Try admin context when install wc * try wc install * adjust phpunit config file * Updated phpunit.xml.dist, composer.json and package.json * Revert install changes * updated npm packages * updated composer lock * updated check assets flow * Updated check assets flow. Yaml file auto formatted. * Updated check assets flow. * Attempt at fixing E2E * Reverted setup permissions step * Add logging information to E2E * Reverted E2E test flow * test playwright perms fix * test e2e perms fix * test e2e perms fix * test e2e perms fix * test e2e perms fix * languages update & debug * languages update & debug * revert * force "@wordpress/env": "^4.9.0" on E2E * update package lock * update package lock --------- Co-authored-by: Mike Jolley <mike.jolley@me.com> Co-authored-by: Niels Lange <info@nielslange.de>
2023-04-21 11:07:37 +00:00
tests_add_filter( 'init', __NAMESPACE__ . '\\manually_install_plugins' );
// Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php';