| | 6 | |
| | 7 | function setUp() { |
| | 8 | parent::setUp(); |
| | 9 | |
| | 10 | register_taxonomy( 'testing-non-slug', array( 'post' ), array( 'labels' => array( 'name' => 'testing-non' ) ) ); |
| | 11 | $this->non_id = wp_insert_term( 'testnon1', 'testing-non-slug' ); |
| | 12 | wp_insert_term( 'testnon2', 'testing-non-slug' ); |
| | 13 | wp_insert_term( 'testnon3', 'testing-non-slug' ); |
| | 14 | wp_insert_term( 'testnon4', 'testing-non-slug' ); |
| | 15 | |
| | 16 | register_taxonomy( 'testing-h-slug', array( 'post' ), array( 'labels' => array( 'name' => 'testing-h', 'hierarchal' => true ) ) ); |
| | 17 | $this->parent_id = wp_insert_term( 'testh1', 'testing-h-slug' ); |
| | 18 | wp_insert_term( 'testh2', 'testing-h-slug', array( 'parent' => $this->parent_id['term_id'] ) ); |
| | 19 | wp_insert_term( 'testh3', 'testing-h-slug', array( 'parent' => $this->parent_id['term_id'] ) ); |
| | 20 | wp_insert_term( 'testh4', 'testing-h-slug', array( 'parent' => $this->parent_id['term_id'] ) ); |
| | 21 | } |
| | 22 | |
| | 65 | |
| | 66 | function test_wp_terms_checklist_decendants_and_self() { |
| | 67 | ob_start(); |
| | 68 | wp_terms_checklist( 0, array( 'decendants_and_self' => 1 ) ); |
| | 69 | $actual = ob_get_clean(); |
| | 70 | $expected = "\n<li id='category-1'><label class=\"selectit\"><input value=\"1\" type=\"checkbox\" name=\"post_category[]\" id=\"in-category-1\" disabled='disabled' /> Uncategorized</label></li>\n"; |
| | 71 | $this->assertSame( $actual, $expected ); |
| | 72 | } |
| | 73 | |
| | 74 | function test_wp_terms_checklist_decendants_and_self_non_hierarchal() { |
| | 75 | ob_start(); |
| | 76 | wp_terms_checklist( 0, array( 'decendants_and_self' => $this->non_id, 'taxonomy' => 'testing-non-slug' ) ); |
| | 77 | $actual = ob_get_clean(); |
| | 78 | $expected = "\n" . '<li id=\'testing-non-slug-26\'><label class="selectit"><input value="26" type="checkbox" name="tax_input[testing-non-slug][]" id="in-testing-non-slug-26" disabled=\'disabled\' /> testnon1</label></li> |
| | 79 | |
| | 80 | <li id=\'testing-non-slug-27\'><label class="selectit"><input value="27" type="checkbox" name="tax_input[testing-non-slug][]" id="in-testing-non-slug-27" disabled=\'disabled\' /> testnon2</label></li> |
| | 81 | |
| | 82 | <li id=\'testing-non-slug-28\'><label class="selectit"><input value="28" type="checkbox" name="tax_input[testing-non-slug][]" id="in-testing-non-slug-28" disabled=\'disabled\' /> testnon3</label></li> |
| | 83 | |
| | 84 | <li id=\'testing-non-slug-29\'><label class="selectit"><input value="29" type="checkbox" name="tax_input[testing-non-slug][]" id="in-testing-non-slug-29" disabled=\'disabled\' /> testnon4</label></li>' . "\n"; |
| | 85 | $this->assertSame( $actual, $expected ); |
| | 86 | } |
| | 87 | |
| | 88 | function test_wp_terms_checklist_decendants_and_self_hierarchal() { |
| | 89 | ob_start(); |
| | 90 | wp_terms_checklist( 0, array( 'decendants_and_self' => $this->parent_id['term_id'], 'taxonomy' => 'testing-h-slug' ) ); |
| | 91 | $actual = ob_get_clean(); |
| | 92 | $expected = "\n" . '<li id=\'testing-h-slug-38\'><label class="selectit"><input value="38" type="checkbox" name="tax_input[testing-h-slug][]" id="in-testing-h-slug-38" disabled=\'disabled\' /> testh1</label><ul class=\'children\'> |
| | 93 | |
| | 94 | <li id=\'testing-h-slug-39\'><label class="selectit"><input value="39" type="checkbox" name="tax_input[testing-h-slug][]" id="in-testing-h-slug-39" disabled=\'disabled\' /> testh2</label></li> |
| | 95 | |
| | 96 | <li id=\'testing-h-slug-40\'><label class="selectit"><input value="40" type="checkbox" name="tax_input[testing-h-slug][]" id="in-testing-h-slug-40" disabled=\'disabled\' /> testh3</label></li> |
| | 97 | |
| | 98 | <li id=\'testing-h-slug-41\'><label class="selectit"><input value="41" type="checkbox" name="tax_input[testing-h-slug][]" id="in-testing-h-slug-41" disabled=\'disabled\' /> testh4</label></li> |
| | 99 | </ul> |
| | 100 | </li>' . "\n"; |
| | 101 | $this->assertSame( $actual, $expected ); |
| | 102 | } |