[dev] PSR-4 naming fixes in tests (part 1) (#51194)
In this PR we address PSR-4 naming-related violations (class FQN vs path mismatches and co) in tests.
This commit is contained in:
parent
70ee1c9f3b
commit
199883a05a
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
|
||||
Coding standatds: fix PSR-4 naming violation in tests (part 1).
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Domain\Package;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Domain;
|
||||
|
||||
use \WP_UnitTestCase;
|
||||
use Automattic\WooCommerce\Blocks\Domain\Package as TestedPackage;
|
||||
use Automattic\WooCommerce\Blocks\Domain\Services\FeatureGating;
|
||||
|
||||
|
@ -11,7 +11,7 @@ use Automattic\WooCommerce\Blocks\Domain\Services\FeatureGating;
|
|||
*
|
||||
* @since $VID:$
|
||||
*/
|
||||
class Package extends WP_UnitTestCase {
|
||||
class Package extends \WP_UnitTestCase {
|
||||
|
||||
private function get_package() {
|
||||
return new TestedPackage( '1.0.0', __DIR__, new FeatureGating() );
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Library;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Domain\Services;
|
||||
|
||||
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
|
||||
use \WC_Order;
|
||||
use Automattic\WooCommerce\Blocks\Domain\Package;
|
||||
use Automattic\WooCommerce\Blocks\Domain\Services\DraftOrders;
|
||||
use Automattic\WooCommerce\Blocks\Domain\Services\FeatureGating;
|
||||
use Automattic\WooCommerce\Blocks\Domain\Package;
|
||||
use WC_Order;
|
||||
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
|
||||
|
||||
/**
|
||||
* Tests Delete Draft Orders functionality
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Library;
|
||||
namespace Automattic\WooCommerce\Tests\Blocks\Domain\Services;
|
||||
|
||||
use Automattic\WooCommerce\Blocks\Package;
|
||||
use Yoast\PHPUnitPolyfills\TestCases\TestCase;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
declare( strict_types = 1);
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Caching;
|
||||
|
||||
use Automattic\WooCommerce\Caches\OrderCache;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Database;
|
||||
|
||||
use WC_Install;
|
||||
|
||||
/**
|
||||
* Tests for the block hooks versioning we set in the DB.
|
||||
*/
|
||||
class BlockHooksVersionTests extends WC_Unit_Test_Case {
|
||||
class BlockHooksVersionTests extends \WC_Unit_Test_Case {
|
||||
/**
|
||||
* Option name for storing the block hooks version.
|
||||
*
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* Tests for PostsToOrdersMigrationController class.
|
||||
*/
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Database\Migrations\CustomOrderTable;
|
||||
|
||||
use Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
||||
use Automattic\WooCommerce\Testing\Tools\DynamicDecorator;
|
||||
use Automattic\WooCommerce\Testing\Tools\ReplacementObject;
|
||||
use Automattic\WooCommerce\Utilities\StringUtil;
|
||||
use WC_DateTime;
|
||||
|
||||
/**
|
||||
* Class PostsToOrdersMigrationControllerTest.
|
||||
*/
|
||||
class PostsToOrdersMigrationControllerTest extends WC_Unit_Test_Case {
|
||||
class PostsToOrdersMigrationControllerTest extends \WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* @var PostsToOrdersMigrationController
|
||||
|
@ -669,7 +669,7 @@ WHERE order_id = {$order_id} AND meta_key = 'non_unique_key_1' AND meta_value in
|
|||
/**
|
||||
* Configure a dynamic decorator for $wpdb that logs (and optionally errors) any db related transaction query.
|
||||
*
|
||||
* @param string|\Exception\bool $transaction_fails False if the transaction related queries won't fail, 'error' if they produce a db error, or an Exception object that they will throw.
|
||||
* @param string|\Exception|bool $transaction_fails False if the transaction related queries won't fail, 'error' if they produce a db error, or an Exception object that they will throw.
|
||||
* @return DynamicDecorator
|
||||
*/
|
||||
private function use_wpdb_mock( $transaction_fails = false ) {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
declare( strict_types = 1);
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\Admin\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Internal\Admin\Orders\EditLock;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
||||
|
@ -6,7 +9,7 @@ use Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
|||
/**
|
||||
* Tests related to order edit locking in admin.
|
||||
*/
|
||||
class EditLockTest extends WC_Unit_Test_Case {
|
||||
class EditLockTest extends \WC_Unit_Test_Case {
|
||||
use HPOSToggleTrait;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\DataStores\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Internal\BatchProcessing\BatchProcessingController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
|
||||
|
@ -7,11 +10,14 @@ use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
|
|||
use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
||||
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
|
||||
use ReflectionClass;
|
||||
use WC_Data_Store;
|
||||
use WC_Order;
|
||||
|
||||
/**
|
||||
* Tests for DataSynchronizer class.
|
||||
*/
|
||||
class DataSynchronizerTests extends HposTestCase {
|
||||
class DataSynchronizerTests extends \HposTestCase {
|
||||
use ArraySubsetAsserts;
|
||||
use HPOSToggleTrait;
|
||||
|
||||
|
@ -141,7 +147,7 @@ class DataSynchronizerTests extends HposTestCase {
|
|||
|
||||
$post_order = OrderHelper::create_order();
|
||||
$this->assertInstanceOf(
|
||||
WP_Post::class,
|
||||
\WP_Post::class,
|
||||
get_post( $post_order->get_id() ),
|
||||
'The order was initially created as a post.'
|
||||
);
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\DataStores\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Internal\BatchProcessing\BatchProcessingController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\LegacyDataCleanup;
|
||||
|
@ -7,7 +11,7 @@ use Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
|||
/**
|
||||
* Tests for the {@see LegacyDataCleanup} class.
|
||||
*/
|
||||
class LegacyDataCleanupTests extends WC_Unit_Test_Case {
|
||||
class LegacyDataCleanupTests extends \WC_Unit_Test_Case {
|
||||
use HPOSToggleTrait;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\DataStores\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\LegacyDataHandler;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
||||
|
||||
/**
|
||||
* Class OrdersTableQueryTests.
|
||||
*/
|
||||
class LegacyDataHandlerTests extends WC_Unit_Test_Case {
|
||||
class LegacyDataHandlerTests extends \WC_Unit_Test_Case {
|
||||
use HPOSToggleTrait;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\DataStores\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
|
||||
use Automattic\WooCommerce\Internal\Features\FeaturesController;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
||||
use Automattic\WooCommerce\Utilities\ArrayUtil as ArrayUtilAlias;
|
||||
use WC_Data_Store;
|
||||
|
||||
if ( ! class_exists( 'WC_REST_Orders_Controller_Tests' ) ) {
|
||||
require_once dirname( __FILE__, 5 ) . '/includes/rest-api/Controllers/Version3/class-wc-rest-orders-controller-tests.php';
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\DataStores\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
|
||||
|
@ -8,13 +11,27 @@ use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableQuery;
|
|||
use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
||||
use Automattic\WooCommerce\Utilities\OrderUtil;
|
||||
use DateTime;
|
||||
use DateTimeZone;
|
||||
use WC_Helper_Order;
|
||||
use WC_Helper_Payment_Token;
|
||||
use WC_Helper_Product;
|
||||
use WC_Order;
|
||||
use WC_Order_Data_Store_CPT;
|
||||
use WC_Order_Item_Product;
|
||||
use WC_Order_Item_Shipping;
|
||||
use WC_Product;
|
||||
use WC_Product_Simple;
|
||||
use WC_Shipping_Rate;
|
||||
use WC_Tax;
|
||||
use WC_Tests_Webhook_Functions;
|
||||
|
||||
/**
|
||||
* Class OrdersTableDataStoreTests.
|
||||
*
|
||||
* Test for OrdersTableDataStore class.
|
||||
*/
|
||||
class OrdersTableDataStoreTests extends HposTestCase {
|
||||
class OrdersTableDataStoreTests extends \HposTestCase {
|
||||
use HPOSToggleTrait;
|
||||
|
||||
/**
|
||||
|
@ -2962,8 +2979,8 @@ class OrdersTableDataStoreTests extends HposTestCase {
|
|||
'total' => '25.00000000',
|
||||
'customer_id' => $order->get_customer_id(),
|
||||
'billing_email' => $order->get_billing_email(),
|
||||
'date_created' => gmdate( 'Y-m-d H:i:s', $order->get_date_created()->format( 'U' ) ),
|
||||
'date_modified' => gmdate( 'Y-m-d H:i:s', $order->get_date_modified()->format( 'U' ) ),
|
||||
'date_created' => gmdate( 'Y-m-d H:i:s', (int) $order->get_date_created()->format( 'U' ) ),
|
||||
'date_modified' => gmdate( 'Y-m-d H:i:s', (int) $order->get_date_modified()->format( 'U' ) ),
|
||||
'parent_id' => $order->get_parent_id(),
|
||||
'payment_method' => $order->get_payment_method(),
|
||||
'payment_method_title' => $order->get_payment_method_title(),
|
||||
|
@ -3000,8 +3017,8 @@ class OrdersTableDataStoreTests extends HposTestCase {
|
|||
'new_order_email_sent' => $order->get_new_order_email_sent(),
|
||||
'order_key' => $order->get_order_key(),
|
||||
'order_stock_reduced' => $order->get_order_stock_reduced(),
|
||||
'date_paid' => gmdate( 'Y-m-d H:i:s', $order->get_date_paid()->format( 'U' ) ),
|
||||
'date_completed' => gmdate( 'Y-m-d H:i:s', $order->get_date_completed()->format( 'U' ) ),
|
||||
'date_paid' => gmdate( 'Y-m-d H:i:s', (int) $order->get_date_paid()->format( 'U' ) ),
|
||||
'date_completed' => gmdate( 'Y-m-d H:i:s', (int) $order->get_date_completed()->format( 'U' ) ),
|
||||
'shipping_tax' => '12.34000000',
|
||||
'shipping_total' => '123.45000000',
|
||||
'discount_tax' => '2.11100000',
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\DataStores\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableQuery;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
||||
use Automattic\WooCommerce\Utilities\OrderUtil;
|
||||
use WC_Helper_Product;
|
||||
use WC_Order;
|
||||
|
||||
/**
|
||||
* Class OrdersTableQueryTests.
|
||||
*/
|
||||
class OrdersTableQueryTests extends WC_Unit_Test_Case {
|
||||
class OrdersTableQueryTests extends \WC_Unit_Test_Case {
|
||||
use HPOSToggleTrait;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,17 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* File containing the class WP_Test_WC_Order_Refund.
|
||||
*/
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\DataStores\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostsToOrdersMigrationController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableRefundDataStore;
|
||||
use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
||||
use WC_Order_Refund;
|
||||
use WC_Order_Refund_Data_Store_CPT;
|
||||
|
||||
/**
|
||||
* Class OrdersTableRefundDataStoreTests.
|
||||
*/
|
||||
class OrdersTableRefundDataStoreTests extends WC_Unit_Test_Case {
|
||||
class OrdersTableRefundDataStoreTests extends \WC_Unit_Test_Case {
|
||||
use \Automattic\WooCommerce\RestApi\UnitTests\HPOSToggleTrait;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
namespace Automattic\WooCommerce\Tests\Internal\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Internal\Orders\IppFunctions;
|
||||
use MobileMessagingHandlerTest;
|
||||
|
||||
|
||||
/**
|
||||
* Tests for IppFunctions.
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
<?php
|
||||
declare( strict_types = 1);
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\Orders;
|
||||
|
||||
use Automattic\WooCommerce\Internal\Orders\MobileMessagingHandler;
|
||||
use DateTime;
|
||||
use WC_Order;
|
||||
|
||||
/**
|
||||
* Tests for MobileMessagingHandler.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\Traits;
|
||||
|
||||
|
@ -429,7 +430,7 @@ class AccessiblePrivateMethodsTest extends \WC_Unit_Test_Case {
|
|||
}
|
||||
}
|
||||
|
||||
//phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound, Squiz.Classes.ClassFileName.NoMatch
|
||||
//phpcs:disable Generic.Files.OneObjectStructurePerFile.MultipleFound, Squiz.Classes.ClassFileName.NoMatch, Suin.Classes.PSR4
|
||||
/**
|
||||
* Class used in the inherited __call method test.
|
||||
*/
|
||||
|
@ -449,4 +450,4 @@ class BaseClass {
|
|||
//phpcs:enable Squiz.Commenting.FunctionComment.Missing
|
||||
}
|
||||
|
||||
//phpcs:enable Generic.Files.OneObjectStructurePerFile.MultipleFound, Squiz.Classes.ClassFileName.NoMatch
|
||||
//phpcs:enable Generic.Files.OneObjectStructurePerFile.MultipleFound, Squiz.Classes.ClassFileName.NoMatch, Suin.Classes.PSR4
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal;
|
||||
namespace Automattic\WooCommerce\Tests\Internal\TransientFiles;
|
||||
|
||||
use Automattic\WooCommerce\Internal\TransientFiles\TransientFilesEngine;
|
||||
|
||||
|
@ -262,7 +263,7 @@ class TransientFilesEngineTest extends \WC_REST_Unit_Test_Case {
|
|||
$fake_wp_filesystem = new class() {
|
||||
public $created_files = array();
|
||||
|
||||
public function put_contents( string $file, string $contents, $mode = false ): bool {
|
||||
public function put_contents( string $file, string $contents, $mode = false ): int {
|
||||
$this->created_files[ $file ] = $contents;
|
||||
return strlen( $contents );
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Tests for COTMigration utility.
|
||||
*/
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\Utilities;
|
||||
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController;
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer;
|
||||
|
@ -11,7 +11,7 @@ use Automattic\WooCommerce\RestApi\UnitTests\Helpers\OrderHelper;
|
|||
/**
|
||||
* Tests for COTMigration utility.
|
||||
*/
|
||||
class COTMigrationUtilTest extends WC_Unit_Test_Case {
|
||||
class COTMigrationUtilTest extends \WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* @var COTMigrationUtil
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* Tests for the DatabaseUtil utility.
|
||||
*/
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\Utilities;
|
||||
|
||||
use Automattic\WooCommerce\Internal\DataStores\Orders\DataSynchronizer;
|
||||
use Automattic\WooCommerce\Internal\Utilities\DatabaseUtil;
|
||||
|
@ -9,7 +9,7 @@ use Automattic\WooCommerce\Internal\Utilities\DatabaseUtil;
|
|||
/**
|
||||
* Tests relating to DatabaseUtil.
|
||||
*/
|
||||
class DatabaseUtilTest extends WC_Unit_Test_Case {
|
||||
class DatabaseUtilTest extends \WC_Unit_Test_Case {
|
||||
|
||||
/**
|
||||
* @var DatabaseUtil
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
/**
|
||||
* Tests for the HtmlSanitizer utility.
|
||||
*/
|
||||
declare( strict_types = 1 );
|
||||
|
||||
namespace Automattic\WooCommerce\Tests\Internal\Utilities;
|
||||
|
||||
use Automattic\WooCommerce\Internal\Utilities\HtmlSanitizer;
|
||||
|
||||
/**
|
||||
* Tests relating to HtmlSanitizer.
|
||||
*/
|
||||
class HtmlSanitizerTest extends WC_Unit_Test_Case {
|
||||
class HtmlSanitizerTest extends \WC_Unit_Test_Case {
|
||||
/**
|
||||
* @var HtmlSanitizer
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue