diff --git a/backend/app/plugins/wiaas/includes/class-wiaas-countries.php b/backend/app/plugins/wiaas/includes/class-wiaas-countries.php index 7d2cbfe..7d14ff3 100644 --- a/backend/app/plugins/wiaas/includes/class-wiaas-countries.php +++ b/backend/app/plugins/wiaas/includes/class-wiaas-countries.php @@ -175,9 +175,7 @@ class Wiaas_Countries { } $name = $choices[$code]; - $result = wp_insert_term($name, 'product_country', array( - 'slug' => $code - )); + $result = wp_insert_term($name, 'product_country'); if (is_wp_error($result)) { continue; diff --git a/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-countries.php b/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-countries.php index 6b45bdc..a352811 100644 --- a/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-countries.php +++ b/backend/app/plugins/wiaas/tests/unit-tests/test-wiaas-countries.php @@ -5,7 +5,7 @@ */ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case { - var $product, $package, $current_country = 'se'; + var $product, $package; public function setUp() { parent::setUp(); @@ -13,10 +13,10 @@ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case { # set admin as current user wp_set_current_user(1); - $this->product = $this->factory->product->create_simple_product(array( 'country' => $this->current_country )); + $this->product = $this->factory->product->create_simple_product(array( 'country' => 'sweden' )); - $this->package = $this->factory->product->create_product_bundle(array( 'country' => $this->current_country )); + $this->package = $this->factory->product->create_product_bundle(array( 'country' => 'sweden' )); } @@ -25,20 +25,9 @@ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case { */ function test_available_countries_created() { // test taxonomy is available - $taxonomy = get_taxonomy('product_country'); + $countries = Wiaas_Countries::get_available_countries(); - $this->assertInstanceOf(WP_Taxonomy::class, $taxonomy); - - $countries = get_terms( - array( - 'taxonomy' => 'product_country', - 'hide_empty' => false, - 'fields' => 'id=>slug' - ) - ); - $country_codes = array_values($countries); - - $this->assertNotEmpty($country_codes); + $country_codes = wp_list_pluck($countries, 'code'); $this->assertContains('se', $country_codes); $this->assertContains('fi', $country_codes); @@ -54,7 +43,7 @@ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case { $this->assertNotNull($retrieved_country, 'Product has not country!'); - $this->assertEquals($retrieved_country['code'], $this->current_country, 'Retrieved product country is incorrect!'); + $this->assertEquals($retrieved_country['name'], 'Sweden', 'Retrieved product country is incorrect!'); } @@ -66,7 +55,7 @@ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case { $this->assertNotNull($retrieved_country, 'Package has not country!'); - $this->assertEquals($retrieved_country['code'], $this->current_country, 'Retrieved package country is incorrect!'); + $this->assertEquals($retrieved_country['name'], 'Sweden', 'Retrieved package country is incorrect!'); } } \ No newline at end of file