Use new code style

This commit is contained in:
David Stone
2025-02-07 19:02:33 -07:00
parent 0181024ae1
commit 8433379d90
672 changed files with 37107 additions and 45249 deletions

View File

@ -11,10 +11,10 @@ class Dashboard_Admin_Page_Test extends WP_UnitTestCase {
*/
public function test_register_scripts() {
// Create a mock instance of Dashboard_Admin_Page and call the register_scripts method
$dashboard_admin_page = $this->getMockBuilder( Dashboard_Admin_Page::class )
->disableOriginalConstructor()
->setMethods( [ 'output' ] )
->getMock();
$dashboard_admin_page = $this->getMockBuilder(Dashboard_Admin_Page::class)
->disableOriginalConstructor()
->setMethods(array('output'))
->getMock();
// Fake dates for testing
$dashboard_admin_page->start_date = '2023-01-01';
@ -24,22 +24,21 @@ class Dashboard_Admin_Page_Test extends WP_UnitTestCase {
$dashboard_admin_page->register_scripts();
// Assert scripts are registered
$this->assertTrue( wp_script_is( 'wu-apex-charts', 'registered' ) );
$this->assertTrue( wp_script_is( 'wu-vue-apex-charts', 'registered' ) );
$this->assertTrue( wp_script_is( 'wu-dashboard-stats', 'registered' ) );
$this->assertTrue(wp_script_is('wu-apex-charts', 'registered'));
$this->assertTrue(wp_script_is('wu-vue-apex-charts', 'registered'));
$this->assertTrue(wp_script_is('wu-dashboard-stats', 'registered'));
// Assert styles are registered
$this->assertTrue( wp_style_is( 'wu-apex-charts', 'registered' ) );
$this->assertTrue(wp_style_is('wu-apex-charts', 'registered'));
// Assert scripts are enqueued
$this->assertTrue( wp_script_is( 'wu-dashboard-stats', 'enqueued' ) );
$this->assertTrue(wp_script_is('wu-dashboard-stats', 'enqueued'));
// Verify localized script data is correct
$localized_vars = wp_scripts()->get_data( 'wu-dashboard-stats', 'data' );
echo( $localized_vars );
$this->assertStringContainsString( '"month_list":["Jan ', $localized_vars );
$this->assertStringContainsString( '"today":"', $localized_vars ); // Check that today is included
$this->assertStringContainsString( '"new_mrr":"New MRR"', $localized_vars );
$localized_vars = wp_scripts()->get_data('wu-dashboard-stats', 'data');
echo($localized_vars);
$this->assertStringContainsString('"month_list":["Jan ', $localized_vars);
$this->assertStringContainsString('"today":"', $localized_vars); // Check that today is included
$this->assertStringContainsString('"new_mrr":"New MRR"', $localized_vars);
}
}
}

View File

@ -30,11 +30,11 @@ class Membership_Edit_Admin_Page_Test extends WP_UnitTestCase {
parent::setUp();
$faker = new Faker();
$faker->generate_fake_memberships();
$this->swap_time = strtotime( '+100 days' );
$this->swap_time = strtotime('+100 days');
$this->membership = current( $faker->get_fake_data_generated( 'memberships' ) );
$cart = new Cart( array() );
$this->membership->schedule_swap( $cart, gmdate( 'Y-m-d H:i:s', $this->swap_time ) );
$this->membership = current($faker->get_fake_data_generated('memberships'));
$cart = new Cart(array());
$this->membership->schedule_swap($cart, gmdate('Y-m-d H:i:s', $this->swap_time));
// Mock Membership_Edit_Admin_Page with dependencies and methods.
$this->membership_edit_admin_page = new Membership_Edit_Admin_Page();
}
@ -48,16 +48,16 @@ class Membership_Edit_Admin_Page_Test extends WP_UnitTestCase {
$this->membership_edit_admin_page->page_loaded();
$membership = $this->membership_edit_admin_page->get_object();
$this->assertInstanceOf( Membership::class, $membership );
$this->assertEquals( $membership->get_id(), $this->membership->get_id() );
$this->assertTrue( $this->membership_edit_admin_page->edit );
$this->assertInstanceOf(Membership::class, $membership);
$this->assertEquals($membership->get_id(), $this->membership->get_id());
$this->assertTrue($this->membership_edit_admin_page->edit);
$notices = \WP_Ultimo()->notices->get_notices( 'network-admin' );
$this->assertNotEmpty( $notices );
$notice = array_shift( $notices );
$this->assertEquals( 'warning', $notice['type'] );
$this->assertFalse( $notice['dismissible_key'] );
$this->assertNotEmpty( $notice['actions'] );
$this->assertStringContainsString( gmdate( get_option( 'date_format' ), $this->swap_time ), $notice['message'] );
$notices = \WP_Ultimo()->notices->get_notices('network-admin');
$this->assertNotEmpty($notices);
$notice = array_shift($notices);
$this->assertEquals('warning', $notice['type']);
$this->assertFalse($notice['dismissible_key']);
$this->assertNotEmpty($notice['actions']);
$this->assertStringContainsString(gmdate(get_option('date_format'), $this->swap_time), $notice['message']);
}
}

View File

@ -8,19 +8,18 @@ use WP_Ultimo\Managers\Gateway_Manager;
class Gateway_Functions_Test extends \WP_UnitTestCase {
public function test_wu_get_gateway_returns_false_for_invalid_id() {
$invalid_gateway_id = 'non_existent_gateway';
$invalid_gateway_id = 'non_existent_gateway';
$result = wu_get_gateway($invalid_gateway_id);
$result = wu_get_gateway($invalid_gateway_id);
$this->assertFalse($result);
$this->assertFalse($result);
}
public function test_wu_get_gateway_returns_instance_for_valid_id() {
$valid_gateway_id = 'manual';
$valid_gateway_id = 'manual';
$gateway = wu_get_gateway($valid_gateway_id);
$gateway = wu_get_gateway($valid_gateway_id);
$this->assertInstanceOf(Manual_Gateway::class, $gateway);
$this->assertInstanceOf(Manual_Gateway::class, $gateway);
}
}

View File

@ -4,8 +4,8 @@ namespace WP_Ultimo;
class Date_Functions_Test extends \WP_UnitTestCase {
public function test_wu_get_days_ago() {
$days = wu_get_days_ago( '2024-01-01 00:00:00', '2024-01-31 00:00:00' );
$days = wu_get_days_ago('2024-01-01 00:00:00', '2024-01-31 00:00:00');
$this->assertEquals( -30, $days );
$this->assertEquals(-30, $days);
}
}

View File

@ -12,11 +12,11 @@ class Discount_Code_Test extends WP_UnitTestCase {
*/
public function test_is_valid_active_discount_code() {
$discount_code = new Discount_Code();
$discount_code->set_active( true );
$discount_code->set_active(true);
$result = $discount_code->is_valid();
$this->assertTrue( $result );
$this->assertTrue($result);
}
/**
@ -24,13 +24,13 @@ class Discount_Code_Test extends WP_UnitTestCase {
*/
public function test_is_valid_inactive_discount_code() {
$discount_code = new Discount_Code();
$discount_code->set_active( false );
$discount_code->set_active(false);
$result = $discount_code->is_valid();
$this->assertInstanceOf( WP_Error::class, $result );
$this->assertEquals( 'discount_code', $result->get_error_code() );
$this->assertEquals( 'This coupon code is not valid.', $result->get_error_message() );
$this->assertInstanceOf(WP_Error::class, $result);
$this->assertEquals('discount_code', $result->get_error_code());
$this->assertEquals('This coupon code is not valid.', $result->get_error_message());
}
/**
@ -38,16 +38,18 @@ class Discount_Code_Test extends WP_UnitTestCase {
*/
public function test_is_valid_max_uses_exceeded() {
$discount_code = new Discount_Code();
$discount_code->set_active( true );
$discount_code->set_max_uses( 5 );
$discount_code->set_uses( 5 );
$discount_code->set_active(true);
$discount_code->set_max_uses(5);
$discount_code->set_uses(5);
$result = $discount_code->is_valid();
$this->assertInstanceOf( WP_Error::class, $result );
$this->assertEquals( 'discount_code', $result->get_error_code() );
$this->assertEquals( 'This discount code was already redeemed the maximum amount of times allowed.',
$result->get_error_message() );
$this->assertInstanceOf(WP_Error::class, $result);
$this->assertEquals('discount_code', $result->get_error_code());
$this->assertEquals(
'This discount code was already redeemed the maximum amount of times allowed.',
$result->get_error_message()
);
}
/**
@ -55,14 +57,14 @@ class Discount_Code_Test extends WP_UnitTestCase {
*/
public function test_is_valid_before_start_date() {
$discount_code = new Discount_Code();
$discount_code->set_active( true );
$discount_code->set_date_start( date( 'Y-m-d H:i:s', strtotime( '+1 day' ) ) );
$discount_code->set_active(true);
$discount_code->set_date_start(date('Y-m-d H:i:s', strtotime('+1 day')));
$result = $discount_code->is_valid();
$this->assertInstanceOf( WP_Error::class, $result );
$this->assertEquals( 'discount_code', $result->get_error_code() );
$this->assertEquals( 'This coupon code is not valid.', $result->get_error_message() );
$this->assertInstanceOf(WP_Error::class, $result);
$this->assertEquals('discount_code', $result->get_error_code());
$this->assertEquals('This coupon code is not valid.', $result->get_error_message());
}
/**
@ -70,14 +72,14 @@ class Discount_Code_Test extends WP_UnitTestCase {
*/
public function test_is_valid_after_expiration_date() {
$discount_code = new Discount_Code();
$discount_code->set_active( true );
$discount_code->set_date_expiration( date( 'Y-m-d H:i:s', strtotime( '-1 day' ) ) );
$discount_code->set_active(true);
$discount_code->set_date_expiration(date('Y-m-d H:i:s', strtotime('-1 day')));
$result = $discount_code->is_valid();
$this->assertInstanceOf( WP_Error::class, $result );
$this->assertEquals( 'discount_code', $result->get_error_code() );
$this->assertEquals( 'This coupon code is not valid.', $result->get_error_message() );
$this->assertInstanceOf(WP_Error::class, $result);
$this->assertEquals('discount_code', $result->get_error_code());
$this->assertEquals('This coupon code is not valid.', $result->get_error_message());
}
/**
@ -86,13 +88,13 @@ class Discount_Code_Test extends WP_UnitTestCase {
public function test_is_valid_for_allowed_product() {
$product_id = 123;
$discount_code = new Discount_Code();
$discount_code->set_active( true );
$discount_code->set_limit_products( true );
$discount_code->set_allowed_products( [ $product_id ] );
$discount_code->set_active(true);
$discount_code->set_limit_products(true);
$discount_code->set_allowed_products(array($product_id));
$result = $discount_code->is_valid( $product_id );
$result = $discount_code->is_valid($product_id);
$this->assertTrue( $result );
$this->assertTrue($result);
}
/**
@ -102,15 +104,15 @@ class Discount_Code_Test extends WP_UnitTestCase {
$allowed_product_id = 123;
$disallowed_product_id = 456;
$discount_code = new Discount_Code();
$discount_code->set_active( true );
$discount_code->set_limit_products( true );
$discount_code->set_allowed_products( [ $allowed_product_id ] );
$discount_code->set_active(true);
$discount_code->set_limit_products(true);
$discount_code->set_allowed_products(array($allowed_product_id));
$result = $discount_code->is_valid( $disallowed_product_id );
$result = $discount_code->is_valid($disallowed_product_id);
$this->assertInstanceOf( WP_Error::class, $result );
$this->assertEquals( 'discount_code', $result->get_error_code() );
$this->assertEquals( 'This coupon code is not valid.', $result->get_error_message() );
$this->assertInstanceOf(WP_Error::class, $result);
$this->assertEquals('discount_code', $result->get_error_code());
$this->assertEquals('This coupon code is not valid.', $result->get_error_message());
}
/**
@ -118,11 +120,11 @@ class Discount_Code_Test extends WP_UnitTestCase {
*/
public function test_is_valid_no_product_limits() {
$discount_code = new Discount_Code();
$discount_code->set_active( true );
$discount_code->set_limit_products( false );
$discount_code->set_active(true);
$discount_code->set_limit_products(false);
$result = $discount_code->is_valid();
$this->assertTrue( $result );
$this->assertTrue($result);
}
}
}

View File

@ -12,10 +12,10 @@ class Domain_Test extends WP_UnitTestCase {
public function test_has_valid_ssl_certificate_with_valid_certificate() {
// Mocking a domain with a valid SSL certificate.
$domain = new Domain();
$domain->set_domain( 'dogs.4thelols.uk' );
$domain->set_domain('dogs.4thelols.uk');
// Assert that it returns true for a valid SSL certificate.
$this->assertTrue( $domain->has_valid_ssl_certificate() );
$this->assertTrue($domain->has_valid_ssl_certificate());
}
/**
@ -24,10 +24,10 @@ class Domain_Test extends WP_UnitTestCase {
public function test_has_valid_ssl_certificate_with_invalid_certificate() {
// Mocking a domain with an invalid SSL certificate.
$domain = new Domain();
$domain->set_domain( 'eeeeeeeeeeeeeeeeauauexample.com' );
$domain->set_domain('eeeeeeeeeeeeeeeeauauexample.com');
// Assert that it returns false for an invalid SSL certificate.
$this->assertFalse( $domain->has_valid_ssl_certificate() );
$this->assertFalse($domain->has_valid_ssl_certificate());
}
/**
@ -36,9 +36,9 @@ class Domain_Test extends WP_UnitTestCase {
public function test_has_valid_ssl_certificate_with_empty_domain() {
// Mocking a domain with an empty value.
$domain = new Domain();
$domain->set_domain( '' );
$domain->set_domain('');
// Assert that it returns false for an empty domain.
$this->assertFalse( $domain->has_valid_ssl_certificate() );
$this->assertFalse($domain->has_valid_ssl_certificate());
}
}
}

View File

@ -26,7 +26,7 @@ class Membership_Test extends \WP_UnitTestCase {
$this->membership = new Membership();
// Set a default customer ID.
$this->membership->set_customer_id( 123 );
$this->membership->set_customer_id(123);
}
/**
@ -34,23 +34,23 @@ class Membership_Test extends \WP_UnitTestCase {
*/
public function test_is_customer_allowed() {
// Admins with 'manage_network' capability should always return true.
$admin_user_id = $this->factory()->user->create( array( 'role' => 'administrator' ) );
grant_super_admin( $admin_user_id );
wp_set_current_user( $admin_user_id );
$this->assertTrue( $this->membership->is_customer_allowed(), 'Failed asserting that admin is allowed.' );
$admin_user_id = $this->factory()->user->create(array('role' => 'administrator'));
grant_super_admin($admin_user_id);
wp_set_current_user($admin_user_id);
$this->assertTrue($this->membership->is_customer_allowed(), 'Failed asserting that admin is allowed.');
// Regular customers are allowed if IDs match.
$customer_id = 123;
$this->assertTrue(
$this->membership->is_customer_allowed( $customer_id ),
$this->membership->is_customer_allowed($customer_id),
'Failed asserting that customer with matching ID is allowed.'
);
// Regular customers are denied if IDs do not match.
$wrong_customer_id = 456;
wp_set_current_user( $wrong_customer_id );
wp_set_current_user($wrong_customer_id);
$this->assertFalse(
$this->membership->is_customer_allowed( $wrong_customer_id ),
$this->membership->is_customer_allowed($wrong_customer_id),
'Failed asserting that customer with non-matching ID is denied.'
);
}
@ -64,14 +64,14 @@ class Membership_Test extends \WP_UnitTestCase {
$faker = new Faker();
$faker->generate_fake_products();
/** @var Product $product */
$product = $faker->get_fake_data_generated( 'products' )[0];
$product = $faker->get_fake_data_generated('products')[0];
$product_id = $product->get_id();
$this->membership->add_product( $product_id, $quantity );
$this->membership->add_product($product_id, $quantity);
// Verify that the product is added with the correct quantity.
$addon_products = $this->membership->get_addon_ids();
$this->assertContains( $product_id, $addon_products, 'Failed asserting that product ID was added.' );
$this->assertContains($product_id, $addon_products, 'Failed asserting that product ID was added.');
$this->assertEquals(
$quantity,
$this->membership->get_addon_products()[0]['quantity'],
@ -80,7 +80,7 @@ class Membership_Test extends \WP_UnitTestCase {
// Add more of the same product and check the updated quantity.
$additional_quantity = 3;
$this->membership->add_product( $product_id, $additional_quantity );
$this->membership->add_product($product_id, $additional_quantity);
$this->assertEquals(
$quantity + $additional_quantity,
@ -98,14 +98,14 @@ class Membership_Test extends \WP_UnitTestCase {
$faker = new Faker();
$faker->generate_fake_products();
/** @var Product $product */
$product = $faker->get_fake_data_generated( 'products' )[0];
$product = $faker->get_fake_data_generated('products')[0];
$product_id = $product->get_id();
$this->membership->add_product( $product_id, $quantity );
$this->membership->add_product($product_id, $quantity);
// Remove some of the product's quantity.
$remove_quantity = 3;
$this->membership->remove_product( $product_id, $remove_quantity );
$this->membership->remove_product($product_id, $remove_quantity);
// Verify the updated quantity.
$this->assertEquals(
@ -115,18 +115,18 @@ class Membership_Test extends \WP_UnitTestCase {
);
// Remove the remaining quantity and verify it is removed.
$this->membership->remove_product( $product_id, $quantity );
$this->membership->remove_product($product_id, $quantity);
$addon_products = $this->membership->get_addon_ids();
$this->assertNotContains( $product_id, $addon_products, 'Failed asserting that the product was removed.' );
$this->assertNotContains($product_id, $addon_products, 'Failed asserting that the product was removed.');
}
/**
* Test get_remaining_days_in_cycle() method.
*/
public function test_get_remaining_days_in_cycle() {
$this->membership->set_amount( 12.99 );
$this->membership->set_amount(12.99);
// Case 1: Non-recurring membership should return 10000.
$this->membership->set_recurring( false );
$this->membership->set_recurring(false);
$this->assertEquals(
10000,
$this->membership->get_remaining_days_in_cycle(),
@ -134,8 +134,8 @@ class Membership_Test extends \WP_UnitTestCase {
);
// Case 2: Invalid expiration date should return 0.
$this->membership->set_recurring( true );
$this->membership->set_date_expiration( 'invalid-date' ); // Setting an invalid date.
$this->membership->set_recurring(true);
$this->membership->set_date_expiration('invalid-date'); // Setting an invalid date.
$this->assertEquals(
0,
$this->membership->get_remaining_days_in_cycle(),
@ -143,7 +143,7 @@ class Membership_Test extends \WP_UnitTestCase {
);
// Case 3: No expiration date should return 0.
$this->membership->set_date_expiration( '' );
$this->membership->set_date_expiration('');
$this->assertEquals(
0,
$this->membership->get_remaining_days_in_cycle(),
@ -151,9 +151,9 @@ class Membership_Test extends \WP_UnitTestCase {
);
// Case 4: Expiration date is in the future and remaining days are calculated properly.
$today = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) );
$today->add( new \DateInterval( 'P10D' ) );
$this->membership->set_date_expiration( $today->format( 'Y-m-d H:i:s' ) );
$today = new \DateTime('now', new \DateTimeZone('UTC'));
$today->add(new \DateInterval('P10D'));
$this->membership->set_date_expiration($today->format('Y-m-d H:i:s'));
$remaining_days = $this->membership->get_remaining_days_in_cycle();
$this->assertEquals(
10,
@ -162,7 +162,7 @@ class Membership_Test extends \WP_UnitTestCase {
);
// Case 5: Expiration date is in the past, should return 0.
$this->membership->set_date_expiration( date( 'Y-m-d H:i:s', strtotime( '-5 days' ) ) );
$this->membership->set_date_expiration(date('Y-m-d H:i:s', strtotime('-5 days')));
$remaining_days = $this->membership->get_remaining_days_in_cycle();
$this->assertEquals(
0,

View File

@ -11,24 +11,24 @@ class Dashboard_Taxes_Tab_Test extends WP_UnitTestCase {
*/
public function test_register_scripts_registers_scripts() {
// Create a mock instance of Dashboard_Admin_Page and call the register_scripts method.
$dashboard_admin_page = $this->getMockBuilder( Dashboard_Taxes_Tab::class )
$dashboard_admin_page = $this->getMockBuilder(Dashboard_Taxes_Tab::class)
->disableOriginalConstructor()
->setMethods( array( 'output' ) )
->setMethods(array('output'))
->getMock();
// Execute register_scripts method.
$dashboard_admin_page->register_scripts();
// Assert scripts are registered.
$this->assertTrue( wp_script_is( 'wu-tax-stats', 'registered' ) );
$this->assertTrue(wp_script_is('wu-tax-stats', 'registered'));
// Assert scripts are enqueued.
$this->assertTrue( wp_script_is( 'wu-tax-stats', 'enqueued' ) );
$this->assertTrue(wp_script_is('wu-tax-stats', 'enqueued'));
// Verify localized script data is correct.
$localized_vars = wp_scripts()->get_data( 'wu-tax-stats', 'data' );
$this->assertStringContainsString( '"month_list":["Jan ', $localized_vars );
$this->assertStringContainsString( '"today":"', $localized_vars ); // Check that today is included.
$this->assertStringContainsString( '"net_profit_label":"Net Profit"', $localized_vars );
$localized_vars = wp_scripts()->get_data('wu-tax-stats', 'data');
$this->assertStringContainsString('"month_list":["Jan ', $localized_vars);
$this->assertStringContainsString('"today":"', $localized_vars); // Check that today is included.
$this->assertStringContainsString('"net_profit_label":"Net Profit"', $localized_vars);
}
}

View File

@ -2,22 +2,22 @@
namespace WP_Ultimo;
class WP_Ultimo_Test extends \WP_UnitTestCase {
/**
* Test if all helper functions are loaded correctly.
*
* This test case creates an instance of the WP_Ultimo class and calls the load_public_apis method.
* It then asserts that the helper functions wu_to_float, wu_replace_dashes, and wu_get_initials are
* correctly loaded. Additional assertions can be added for other helper functions.
*
* @return void
*/
public function testLoadAllHelperFunctionsCorrectly() {
// Assert that all helper functions are loaded correctly.
// This is all done in the bootstrap.
$this->assertTrue(function_exists('wu_to_float'));
$this->assertTrue(function_exists('wu_replace_dashes'));
$this->assertTrue(function_exists('wu_get_initials'));
}
/**
* Test if all helper functions are loaded correctly.
*
* This test case creates an instance of the WP_Ultimo class and calls the load_public_apis method.
* It then asserts that the helper functions wu_to_float, wu_replace_dashes, and wu_get_initials are
* correctly loaded. Additional assertions can be added for other helper functions.
*
* @return void
*/
public function testLoadAllHelperFunctionsCorrectly() {
// Assert that all helper functions are loaded correctly.
// This is all done in the bootstrap.
$this->assertTrue(function_exists('wu_to_float'));
$this->assertTrue(function_exists('wu_replace_dashes'));
$this->assertTrue(function_exists('wu_get_initials'));
}
public function testLoaded() {
$wpUltimo = \WP_Ultimo();
@ -27,8 +27,8 @@ class WP_Ultimo_Test extends \WP_UnitTestCase {
public function testPublicProperties() {
$wpUltimo = \WP_Ultimo();
$this->assertTrue($wpUltimo->settings instanceof Settings);
$this->assertTrue($wpUltimo->helper instanceof Helper);
$this->assertTrue($wpUltimo->settings instanceof Settings);
$this->assertTrue($wpUltimo->helper instanceof Helper);
$this->assertTrue($wpUltimo->notices instanceof Admin_Notices);
$this->assertTrue($wpUltimo->scripts instanceof Scripts);
$this->assertTrue($wpUltimo->currents instanceof Current);

View File

@ -5,21 +5,21 @@
* @package Wp_Multisite_Waas
*/
$_tests_dir = getenv( 'WP_TESTS_DIR' );
$_tests_dir = getenv('WP_TESTS_DIR');
require 'vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php';
if ( ! $_tests_dir ) {
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib';
$_tests_dir = rtrim(sys_get_temp_dir(), '/\\') . '/wordpress-tests-lib';
}
// Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file.
$_phpunit_polyfills_path = getenv( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' );
$_phpunit_polyfills_path = getenv('WP_TESTS_PHPUNIT_POLYFILLS_PATH');
if ( false !== $_phpunit_polyfills_path ) {
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path );
define('WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path);
}
if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) {
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 );
exit(1);
}
// Give access to tests_add_filter() function.
@ -29,10 +29,10 @@ require_once "{$_tests_dir}/includes/functions.php";
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
require dirname( dirname( __FILE__ ) ) . '/wp-multisite-waas.php';
require dirname(__DIR__) . '/wp-multisite-waas.php';
}
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
// Start up the WP testing environment.
require "{$_tests_dir}/includes/bootstrap.php";