Fix countries

This commit is contained in:
Almira Krdzic
2018-12-02 22:59:20 +01:00
parent e87d1521dd
commit 670eb53da1
2 changed files with 8 additions and 21 deletions

View File

@@ -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;

View File

@@ -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!');
}
}