Ticket #22023: 22023.term_exists-tests.diff
File 22023.term_exists-tests.diff, 1.9 KB (added by , 11 years ago) |
---|
-
tests/phpunit/tests/term.php
55 55 56 56 function test_term_exists_known() { 57 57 // insert a term 58 $term = rand_str(); 59 $t = wp_insert_term( $term, $this->taxonomy ); 60 $this->assertInternalType( 'array', $t ); 61 $this->assertEquals( $t['term_id'], term_exists($t['term_id']) ); 62 $this->assertEquals( $t['term_id'], term_exists($term) ); 58 $term_k_name = 'kierkegaard'; 59 $term_k = wp_insert_term( 'kierkegaard', $this->taxonomy ); 60 $this->assertInternalType( 'array', $term_k ); 61 $this->assertEquals( $term_k['term_id'], term_exists($term_k['term_id']) ); 62 $this->assertEquals( $term_k['term_id'], term_exists($term_k_name) ); 63 $term_k_in_tax = term_exists( $term_k['term_id'], $this->taxonomy ); 64 $this->assertEquals( $term_k['term_id'], $term_k_in_tax['term_id'] ); 63 65 66 $term_s = wp_insert_term( 'satre', $this->taxonomy, array( 'parent' => $term_k['term_id'] ) ); 67 $this->assertFalse( is_wp_error( $term_s ) ); 68 $this->assertEquals( $term_s['term_id'], term_exists($term_s['term_id']) ); 69 $term_s_in_tax_with_parent = term_exists( $term_s['term_id'], $this->taxonomy, $term_k['term_id'] ); 70 $this->assertEquals( $term_s['term_id'], $term_s_in_tax_with_parent['term_id'] ); 71 64 72 // clean up 65 $this->assertTrue( wp_delete_term($t['term_id'], $this->taxonomy) ); 73 wp_delete_term($term_k['term_id'], $this->taxonomy); 74 wp_delete_term($term_s['term_id'], $this->taxonomy); 66 75 } 67 76 68 77 function test_term_exists_unknown() { 69 $this->assertNull( term_exists( rand_str()) );78 $this->assertNull( term_exists('nothing') ); 70 79 $this->assertEquals( 0, term_exists(0) ); 80 $this->assertEquals( 0, term_exists(99999) ); 71 81 $this->assertEquals( 0, term_exists('') ); 72 82 $this->assertEquals( 0, term_exists(NULL) ); 73 83 }