Fix assigment order issues

This commit is contained in:
Almira Krdzic
2018-12-02 22:18:09 +01:00
parent 3dbdb657c9
commit e87d1521dd
23 changed files with 873 additions and 256 deletions

View File

@@ -5,7 +5,7 @@
*/
class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case {
var $product, $package, $current_country = 'Sweden';
var $product, $package, $current_country = 'se';
public function setUp() {
parent::setUp();
@@ -13,14 +13,10 @@ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case {
# set admin as current user
wp_set_current_user(1);
$this->product = $this->create_new_product();
wp_set_object_terms($this->product->get_id(), $this->current_country, 'product_country', false);
clean_object_term_cache( $this->product->get_id(), 'product_country' );
$this->product = $this->factory->product->create_simple_product(array( 'country' => $this->current_country ));
$this->package = $this->create_new_package();
wp_set_object_terms($this->package->get_id(), $this->current_country, 'product_country', false);
clean_object_term_cache( $this->package->get_id(), 'product_country' );
$this->package = $this->factory->product->create_product_bundle(array( 'country' => $this->current_country ));
}
@@ -33,15 +29,20 @@ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case {
$this->assertInstanceOf(WP_Taxonomy::class, $taxonomy);
$country_names = array_map(function($term) {
return $term->name;
}, get_terms(array( 'taxonomy' => 'product_country', 'hide_empty' => false )));
$countries = get_terms(
array(
'taxonomy' => 'product_country',
'hide_empty' => false,
'fields' => 'id=>slug'
)
);
$country_codes = array_values($countries);
$this->assertNotEmpty($country_names);
$this->assertNotEmpty($country_codes);
$this->assertContains('Sweden', $country_names);
$this->assertContains('Denmark', $country_names);
$this->assertContains('Finland', $country_names);
$this->assertContains('se', $country_codes);
$this->assertContains('fi', $country_codes);
$this->assertContains('dk', $country_codes);
}
/**
@@ -53,7 +54,7 @@ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case {
$this->assertNotNull($retrieved_country, 'Product has not country!');
$this->assertEquals($retrieved_country['name'], $this->current_country, 'Retrieved product country is incorrect!');
$this->assertEquals($retrieved_country['code'], $this->current_country, 'Retrieved product country is incorrect!');
}
@@ -65,7 +66,7 @@ class Wiaas_Countries_Test extends Wiaas_Unit_Test_Case {
$this->assertNotNull($retrieved_country, 'Package has not country!');
$this->assertEquals($retrieved_country['name'], $this->current_country, 'Retrieved package country is incorrect!');
$this->assertEquals($retrieved_country['code'], $this->current_country, 'Retrieved package country is incorrect!');
}
}