| | 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 | |
| | 128 | function test_wp_terms_checklist_decendants_and_self() { |
| | 129 | ob_start(); |
| | 130 | wp_terms_checklist( 0, array( 'decendants_and_self' => 1 ) ); |
| | 131 | $actual = ob_get_clean(); |
| | 132 | $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"; |
| | 133 | $this->assertSame( $actual, $expected ); |
| | 134 | } |
| | 135 | |
| | 136 | function test_wp_terms_checklist_decendants_and_self_non_hierarchal() { |
| | 137 | ob_start(); |
| | 138 | wp_terms_checklist( 0, array( 'decendants_and_self' => $this->non_id, 'taxonomy' => 'testing-non-slug' ) ); |
| | 139 | $actual = ob_get_clean(); |
| | 140 | $expected = "\n" . '<li id=\'testing-non-slug-62\'><label class="selectit"><input value="62" type="checkbox" name="tax_input[testing-non-slug][]" id="in-testing-non-slug-62" disabled=\'disabled\' /> testnon1</label></li> |
| | 141 | |
| | 142 | <li id=\'testing-non-slug-63\'><label class="selectit"><input value="63" type="checkbox" name="tax_input[testing-non-slug][]" id="in-testing-non-slug-63" disabled=\'disabled\' /> testnon2</label></li> |
| | 143 | |
| | 144 | <li id=\'testing-non-slug-64\'><label class="selectit"><input value="64" type="checkbox" name="tax_input[testing-non-slug][]" id="in-testing-non-slug-64" disabled=\'disabled\' /> testnon3</label></li> |
| | 145 | |
| | 146 | <li id=\'testing-non-slug-65\'><label class="selectit"><input value="65" type="checkbox" name="tax_input[testing-non-slug][]" id="in-testing-non-slug-65" disabled=\'disabled\' /> testnon4</label></li>' . "\n"; |
| | 147 | $this->assertSame( $actual, $expected ); |
| | 148 | } |
| | 149 | |
| | 150 | function test_wp_terms_checklist_decendants_and_self_hierarchal() { |
| | 151 | ob_start(); |
| | 152 | wp_terms_checklist( 0, array( 'decendants_and_self' => $this->parent_id['term_id'], 'taxonomy' => 'testing-h-slug' ) ); |
| | 153 | $actual = ob_get_clean(); |
| | 154 | $expected = "\n" . '<li id=\'testing-h-slug-74\'><label class="selectit"><input value="74" type="checkbox" name="tax_input[testing-h-slug][]" id="in-testing-h-slug-74" disabled=\'disabled\' /> testh1</label><ul class=\'children\'> |
| | 155 | |
| | 156 | <li id=\'testing-h-slug-75\'><label class="selectit"><input value="75" type="checkbox" name="tax_input[testing-h-slug][]" id="in-testing-h-slug-75" disabled=\'disabled\' /> testh2</label></li> |
| | 157 | |
| | 158 | <li id=\'testing-h-slug-76\'><label class="selectit"><input value="76" type="checkbox" name="tax_input[testing-h-slug][]" id="in-testing-h-slug-76" disabled=\'disabled\' /> testh3</label></li> |
| | 159 | |
| | 160 | <li id=\'testing-h-slug-77\'><label class="selectit"><input value="77" type="checkbox" name="tax_input[testing-h-slug][]" id="in-testing-h-slug-77" disabled=\'disabled\' /> testh4</label></li> |
| | 161 | </ul> |
| | 162 | </li>' . "\n"; |
| | 163 | $this->assertSame( $actual, $expected ); |
| | 164 | } |
| | 165 | |