예제 #1
0
 /**
  * Test product term setters and getters
  * @since 2.7.0
  */
 public function test_product_term_getters_and_setters()
 {
     $test_cat_1 = wp_insert_term('Testing 1', 'product_cat');
     $test_cat_2 = wp_insert_term('Testing 2', 'product_cat');
     $test_tag_1 = wp_insert_term('Tag 1', 'product_tag');
     $test_tag_2 = wp_insert_term('Tag 2', 'product_tag');
     $getters_and_setters = array('tag_ids' => array('Tag 1', 'Tag 2'), 'category_ids' => array($test_cat_1['term_id'], $test_cat_2['term_id']));
     $product = new WC_Product_Simple();
     foreach ($getters_and_setters as $function => $value) {
         $product->{"set_{$function}"}($value);
     }
     $product->save();
     $this->assertEquals(array($test_cat_1['term_id'], $test_cat_2['term_id']), $product->get_category_ids());
     $this->assertEquals(array($test_tag_1['term_id'], $test_tag_2['term_id']), $product->get_tag_ids());
 }