diff --git a/plugins/woocommerce/changelog/dev-psr4-naming-fixes-part-2 b/plugins/woocommerce/changelog/dev-psr4-naming-fixes-part-2
new file mode 100644
index 00000000000..bd60605e513
--- /dev/null
+++ b/plugins/woocommerce/changelog/dev-psr4-naming-fixes-part-2
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+Coding standatds: fix PSR-4 naming violation in tests (part 2).
diff --git a/plugins/woocommerce/phpcs.xml b/plugins/woocommerce/phpcs.xml
index 3f0931e607c..fc1aae09313 100644
--- a/plugins/woocommerce/phpcs.xml
+++ b/plugins/woocommerce/phpcs.xml
@@ -55,11 +55,16 @@
tests/php/src/
plugins/woocommerce/src/Admin/Notes/DeprecatedNotes.php
plugins/woocommerce/tests/php/src/Proxies/ExampleClasses/
+ plugins/woocommerce/tests/php/src/Internal/DependencyManagement/ExampleClasses/
+
+ plugins/woocommerce/tests/php/src/Blocks/Mocks/
+
+
includes/
lib/
diff --git a/plugins/woocommerce/tests/php/src/Admin/ShippingPartnerSuggestions/DefaultShippingPartnersTest.php b/plugins/woocommerce/tests/php/src/Admin/ShippingPartnerSuggestions/DefaultShippingPartnersTest.php
index 041488b0342..ecea313caa7 100644
--- a/plugins/woocommerce/tests/php/src/Admin/ShippingPartnerSuggestions/DefaultShippingPartnersTest.php
+++ b/plugins/woocommerce/tests/php/src/Admin/ShippingPartnerSuggestions/DefaultShippingPartnersTest.php
@@ -1,6 +1,7 @@
getProperty( 'db_upgrades' );
@@ -32,6 +54,9 @@ class MigrationTest extends \WP_UnitTestCase {
return $mock;
}
+ /**
+ * Test running single migration.
+ */
public function test_migrations_run() {
update_option( Options::WC_BLOCK_VERSION, '1.0.0' );
@@ -53,6 +78,9 @@ class MigrationTest extends \WP_UnitTestCase {
$mock->run_migrations();
}
+ /**
+ * Test running multiple migrations.
+ */
public function test_multiple_migrations_run() {
update_option( Options::WC_BLOCK_VERSION, '0.0.9' );
@@ -76,6 +104,9 @@ class MigrationTest extends \WP_UnitTestCase {
$mock->run_migrations();
}
+ /**
+ * Test skipping executed migrations.
+ */
public function test_skip_migrations() {
update_option( Options::WC_BLOCK_VERSION, '2.0.0' );
@@ -95,6 +126,9 @@ class MigrationTest extends \WP_UnitTestCase {
$mock->run_migrations();
}
+ /**
+ * Test skipping executed migrations.
+ */
public function test_skip_migrations_when_missing_version_option() {
$mock = Mockery::mock( Migration::class )->makePartial();
@@ -112,5 +146,4 @@ class MigrationTest extends \WP_UnitTestCase {
$mock->run_migrations();
}
-
}
diff --git a/plugins/woocommerce/tests/php/src/Blocks/Mocks/AssetDataRegistryMock.php b/plugins/woocommerce/tests/php/src/Blocks/Mocks/AssetDataRegistryMock.php
new file mode 100644
index 00000000000..22f5ca430cd
--- /dev/null
+++ b/plugins/woocommerce/tests/php/src/Blocks/Mocks/AssetDataRegistryMock.php
@@ -0,0 +1,70 @@
+debug = $debug;
+ }
+
+ /**
+ * Returns the debug flag value.
+ *
+ * @return bool
+ */
+ protected function debug() {
+ return $this->debug;
+ }
+
+ /**
+ * Exposes private registered data to child classes.
+ *
+ * @return array The registered data on the private data property
+ */
+ public function get() {
+ return parent::get();
+ }
+
+ /**
+ * Used for on demand initialization of asset data and registering it with
+ * the internal data registry.
+ *
+ * Note: core data will overwrite any externally registered data via the api.
+ */
+ public function initialize_core_data() {
+ parent::initialize_core_data();
+ }
+
+ /**
+ * Loops through each registered lazy data callback and adds the returned
+ * value to the data array.
+ *
+ * This method is executed right before preparing the data for printing to
+ * the rendered screen.
+ *
+ * @return void
+ */
+ public function execute_lazy_data() {
+ parent::execute_lazy_data();
+ }
+}
diff --git a/plugins/woocommerce/tests/php/src/Blocks/mocks/BlockHooksTestBlock.php b/plugins/woocommerce/tests/php/src/Blocks/Mocks/BlockHooksTestBlock.php
similarity index 100%
rename from plugins/woocommerce/tests/php/src/Blocks/mocks/BlockHooksTestBlock.php
rename to plugins/woocommerce/tests/php/src/Blocks/Mocks/BlockHooksTestBlock.php
diff --git a/plugins/woocommerce/tests/php/src/Blocks/mocks/CartCheckoutUtilsMock.php b/plugins/woocommerce/tests/php/src/Blocks/Mocks/CartCheckoutUtilsMock.php
similarity index 59%
rename from plugins/woocommerce/tests/php/src/Blocks/mocks/CartCheckoutUtilsMock.php
rename to plugins/woocommerce/tests/php/src/Blocks/Mocks/CartCheckoutUtilsMock.php
index 1bb4627eca1..b8a42689683 100644
--- a/plugins/woocommerce/tests/php/src/Blocks/mocks/CartCheckoutUtilsMock.php
+++ b/plugins/woocommerce/tests/php/src/Blocks/Mocks/CartCheckoutUtilsMock.php
@@ -1,4 +1,6 @@
dependency = $dependency;
}
-};
+}
diff --git a/plugins/woocommerce/tests/php/src/Blocks/mocks/OrderConfirmation/TotalsMock.php b/plugins/woocommerce/tests/php/src/Blocks/Mocks/OrderConfirmation/TotalsMock.php
similarity index 73%
rename from plugins/woocommerce/tests/php/src/Blocks/mocks/OrderConfirmation/TotalsMock.php
rename to plugins/woocommerce/tests/php/src/Blocks/Mocks/OrderConfirmation/TotalsMock.php
index 611d6317149..4f983b8480f 100644
--- a/plugins/woocommerce/tests/php/src/Blocks/mocks/OrderConfirmation/TotalsMock.php
+++ b/plugins/woocommerce/tests/php/src/Blocks/Mocks/OrderConfirmation/TotalsMock.php
@@ -1,4 +1,6 @@
cart->add_to_cart( $out_of_stock_product->get_id(), 2 );
$out_of_stock_in_cart = wc()->cart->get_cart_item( $out_of_stock_product_key )['data'];
- // This product will have exact levels of stock known
+ // This product will have exact levels of stock known.
$partially_out_of_stock_product = $fixtures->get_simple_product(
array(
'name' => 'Test Product 2',
@@ -35,7 +38,7 @@ class CartControllerTests extends TestCase {
$partially_out_of_stock_key = wc()->cart->add_to_cart( $partially_out_of_stock_product->get_id(), 4 );
$partially_out_of_stock_in_cart = wc()->cart->get_cart_item( $partially_out_of_stock_key )['data'];
- // This product will have exact levels of stock known
+ // This product will have exact levels of stock known.
$too_many_in_cart_product = $fixtures->get_simple_product(
array(
'name' => 'Test Product 3',
@@ -50,7 +53,7 @@ class CartControllerTests extends TestCase {
$partially_out_of_stock_in_cart->set_stock_quantity( 2 );
$too_many_in_cart_in_cart->set_sold_individually( true );
- // This product will not be purchasable
+ // This product will not be purchasable.
$not_purchasable_product = $fixtures->get_simple_product(
array(
'name' => 'Test Product 4',
@@ -59,10 +62,10 @@ class CartControllerTests extends TestCase {
);
wc()->cart->add_to_cart( $not_purchasable_product->get_id(), 2 );
- // This function will force the $product->is_purchasable() function to return false for our $not_purchasable_product
+ // This function will force the $product->is_purchasable() function to return false for our $not_purchasable_product.
add_filter(
'woocommerce_is_purchasable',
- function( $is_purchasable, $product ) use ( $not_purchasable_product ) {
+ function ( $is_purchasable, $product ) use ( $not_purchasable_product ) {
if ( $product->get_id() === $not_purchasable_product->get_id() ) {
return false;
}
@@ -88,7 +91,5 @@ class CartControllerTests extends TestCase {
foreach ( $expected_errors as $expected_error ) {
$this->assertContains( $expected_error, $error_codes );
}
-
}
-
}
diff --git a/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Utilities/NoticeHandler.php b/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Utilities/NoticeHandlerTests.php
similarity index 97%
rename from plugins/woocommerce/tests/php/src/Blocks/StoreApi/Utilities/NoticeHandler.php
rename to plugins/woocommerce/tests/php/src/Blocks/StoreApi/Utilities/NoticeHandlerTests.php
index d0c5c6aa2ae..25ddafb19ba 100644
--- a/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Utilities/NoticeHandler.php
+++ b/plugins/woocommerce/tests/php/src/Blocks/StoreApi/Utilities/NoticeHandlerTests.php
@@ -1,7 +1,5 @@
debug = $debug;
- }
-
- public function initialize_core_data() {
- return parent::initialize_core_data();
- }
-
- protected function debug() {
- return $this->debug;
- }
-}
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/MarketingRecommendations/InitTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/MarketingRecommendations/InitTest.php
index c4fb8a3f715..6ba09798c8f 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/MarketingRecommendations/InitTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Admin/MarketingRecommendations/InitTest.php
@@ -1,11 +1,12 @@