Moved test to correct directory

This commit is contained in:
Christopher Allford 2020-07-15 07:08:09 -07:00
parent c9f754f5a3
commit fdee8dceaf
3 changed files with 34 additions and 23 deletions

View File

@ -45,8 +45,8 @@
},
"autoload-dev": {
"psr-4": {
"Automattic\\WooCommerce\\Tests\\": "tests/php/src",
"Automattic\\WooCommerce\\Testing\\Tools\\": "tests/Tools"
"Automattic\\WooCommerce\\Tests\\": "tests/php/src/",
"Automattic\\WooCommerce\\Testing\\Tools\\": "tests/Tools/"
}
},
"scripts": {

View File

@ -96,27 +96,6 @@ class WC_Tests_Admin_Duplicate_Product extends WC_Unit_Test_Case {
}
}
/**
* Tests that the filter will exclude metadata from the duplicate as-expected.
*/
public function test_filter_allows_excluding_metadata_from_duplicate() {
$product = WC_Helper_Product::create_simple_product();
$product->add_meta_data( 'test_data', 'test' );
$filter = function ( $exclude_meta, $existing_meta_keys ) {
$this->assertContains( 'test_data', $existing_meta_keys );
return array( 'test_data' );
};
add_filter( 'woocommerce_duplicate_product_exclude_meta', $filter, 10, 2 );
$duplicate = ( new WC_Admin_Duplicate_Product() )->product_duplicate( $product );
remove_filter( 'woocommerce_duplicate_product_exclude_meta', $filter );
$this->assertNotEquals( $product->get_id(), $duplicate->get_id() );
$this->assertEmpty( $duplicate->get_meta_data() );
}
/**
* Asserts that the product was correctly reset after duplication.
*

View File

@ -0,0 +1,32 @@
<?php
/**
* Unit tests for the WC_Admin_Duplicate_Product class.
*
* @package WooCommerce\Tests\Admin
*/
/**
* Class WC_Admin_Duplicate_Product_Test
*/
class WC_Admin_Duplicate_Product_Test extends WC_Unit_Test_Case {
/**
* Tests that the filter will exclude metadata from the duplicate as-expected.
*/
public function test_filter_allows_excluding_metadata_from_duplicate() {
$product = WC_Helper_Product::create_simple_product();
$product->add_meta_data( 'test_data', 'test' );
$filter = function ( $exclude_meta, $existing_meta_keys ) {
$this->assertContains( 'test_data', $existing_meta_keys );
return array( 'test_data' );
};
add_filter( 'woocommerce_duplicate_product_exclude_meta', $filter, 10, 2 );
$duplicate = ( new WC_Admin_Duplicate_Product() )->product_duplicate( $product );
remove_filter( 'woocommerce_duplicate_product_exclude_meta', $filter );
$this->assertNotEquals( $product->get_id(), $duplicate->get_id() );
$this->assertEmpty( $duplicate->get_meta_data() );
}
}