Changeset 11095 for trunk/tests/phpunit/testcases/groups/template.php
- Timestamp:
- 09/13/2016 06:21:10 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/template.php
r9819 r11095 118 118 119 119 $this->assertEquals( 1, $groups_template->group_count ); 120 } 121 122 /** 123 * @group hierarchical_groups 124 */ 125 public function test_bp_has_groups_parent_id() { 126 $g1 = $this->factory->group->create(); 127 $g2 = $this->factory->group->create( array( 128 'parent_id' => $g1, 129 ) ); 130 $g3 = $this->factory->group->create( array( 131 'parent_id' => $g2, 132 ) ); 133 $g4 = $this->factory->group->create(); 134 135 global $groups_template; 136 bp_has_groups( array( 137 'parent_id' => $g1, 138 ) ); 139 140 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) ); 141 $this->assertEquals( array( $g2 ), $ids ); 142 } 143 144 /** 145 * @group hierarchical_groups 146 */ 147 public function test_bp_has_groups_parent_id_array() { 148 $g1 = $this->factory->group->create(); 149 $g2 = $this->factory->group->create( array( 150 'parent_id' => $g1, 151 ) ); 152 $g3 = $this->factory->group->create( array( 153 'parent_id' => $g2, 154 ) ); 155 $g4 = $this->factory->group->create(); 156 157 global $groups_template; 158 bp_has_groups( array( 159 'parent_id' => array( $g1, $g2 ), 160 ) ); 161 162 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) ); 163 $this->assertEqualSets( array( $g2, $g3 ), $ids ); 164 } 165 166 /** 167 * @group hierarchical_groups 168 */ 169 public function test_bp_has_groups_parent_id_comma_separated() { 170 $g1 = $this->factory->group->create(); 171 $g2 = $this->factory->group->create( array( 172 'parent_id' => $g1, 173 ) ); 174 $g3 = $this->factory->group->create( array( 175 'parent_id' => $g2, 176 ) ); 177 $g4 = $this->factory->group->create(); 178 179 global $groups_template; 180 bp_has_groups( array( 181 'parent_id' => "{$g1},{$g2}", 182 ) ); 183 184 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) ); 185 $this->assertEqualSets( array( $g2, $g3 ), $ids ); 186 } 187 188 /** 189 * @group hierarchical_groups 190 */ 191 public function test_bp_has_groups_parent_id_null() { 192 $g1 = $this->factory->group->create(); 193 $g2 = $this->factory->group->create( array( 194 'parent_id' => $g1, 195 ) ); 196 $g3 = $this->factory->group->create( array( 197 'parent_id' => $g2, 198 ) ); 199 $g4 = $this->factory->group->create(); 200 201 global $groups_template; 202 bp_has_groups( array( 203 'parent_id' => null, 204 ) ); 205 206 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) ); 207 $this->assertEqualSets( array( $g1, $g2, $g3, $g4 ), $ids ); 208 } 209 210 /** 211 * @group hierarchical_groups 212 */ 213 public function test_bp_has_groups_parent_id_top_level_groups() { 214 $g1 = $this->factory->group->create(); 215 $g2 = $this->factory->group->create( array( 216 'parent_id' => $g1, 217 ) ); 218 $g3 = $this->factory->group->create( array( 219 'parent_id' => $g2, 220 ) ); 221 $g4 = $this->factory->group->create(); 222 223 global $groups_template; 224 bp_has_groups( array( 225 'parent_id' => 0, 226 ) ); 227 228 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) ); 229 $this->assertEqualSets( array( $g1, $g4 ), $ids ); 230 } 231 232 /** 233 * @group hierarchical_groups 234 */ 235 public function test_bp_has_groups_parent_id_top_level_groups_using_false() { 236 $g1 = $this->factory->group->create(); 237 $g2 = $this->factory->group->create( array( 238 'parent_id' => $g1, 239 ) ); 240 $g3 = $this->factory->group->create( array( 241 'parent_id' => $g2, 242 ) ); 243 $g4 = $this->factory->group->create(); 244 245 global $groups_template; 246 bp_has_groups( array( 247 'parent_id' => false, 248 ) ); 249 250 $ids = wp_parse_id_list( wp_list_pluck( $groups_template->groups, 'id' ) ); 251 $this->assertEqualSets( array( $g1, $g4 ), $ids ); 120 252 } 121 253
Note: See TracChangeset
for help on using the changeset viewer.