Moved test to correct directory
This commit is contained in:
parent
c9f754f5a3
commit
fdee8dceaf
|
@ -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": {
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue