product = $this->factory->product->create_simple_product(array( 'country' => $this->current_country )); $this->package = $this->factory->product->create_product_bundle(array( 'country' => $this->current_country )); } /** * @covers Wiaas_Countries::register_product_countries_taxonomy() */ function test_available_countries_created() { // test taxonomy is available $taxonomy = get_taxonomy('product_country'); $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); $this->assertContains('se', $country_codes); $this->assertContains('fi', $country_codes); $this->assertContains('dk', $country_codes); } /** * @covers Wiaas_Countries::get_product_country() */ function test_get_product_country() { $retrieved_country = Wiaas_Countries::get_product_country($this->product); $this->assertNotNull($retrieved_country, 'Product has not country!'); $this->assertEquals($retrieved_country['code'], $this->current_country, 'Retrieved product country is incorrect!'); } /** * @covers Wiaas_Countries::get_package_country() */ function test_get_package_country() { $retrieved_country = Wiaas_Countries::get_package_country($this->package); $this->assertNotNull($retrieved_country, 'Package has not country!'); $this->assertEquals($retrieved_country['code'], $this->current_country, 'Retrieved package country is incorrect!'); } }