- Timestamp:
- 09/13/2016 06:21:10 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php
r11091 r11095 1706 1706 $this->assertEmpty( $groups['groups'] ); 1707 1707 } 1708 1709 /** 1710 * @group hierarchical_groups 1711 */ 1712 public function test_get_by_parent_id() { 1713 $g1 = $this->factory->group->create(); 1714 $g2 = $this->factory->group->create( array( 1715 'parent_id' => $g1, 1716 ) ); 1717 $g3 = $this->factory->group->create( array( 1718 'parent_id' => $g2, 1719 ) ); 1720 $g4 = $this->factory->group->create(); 1721 1722 $groups = BP_Groups_Group::get( array( 1723 'parent_id' => $g1, 1724 ) ); 1725 1726 $found = wp_list_pluck( $groups['groups'], 'id' ); 1727 $this->assertEquals( array( $g2 ), $found ); 1728 } 1729 1730 /** 1731 * @group hierarchical_groups 1732 */ 1733 public function test_get_by_parent_id_ignore_grandparent() { 1734 $g1 = $this->factory->group->create(); 1735 $g2 = $this->factory->group->create( array( 1736 'parent_id' => $g1, 1737 ) ); 1738 $g3 = $this->factory->group->create( array( 1739 'parent_id' => $g2, 1740 ) ); 1741 $g4 = $this->factory->group->create(); 1742 1743 $groups = BP_Groups_Group::get( array( 1744 'parent_id' => $g2, 1745 ) ); 1746 1747 $found = wp_list_pluck( $groups['groups'], 'id' ); 1748 $this->assertEquals( array( $g3 ), $found ); 1749 } 1750 1751 /** 1752 * @group hierarchical_groups 1753 */ 1754 public function test_get_by_parent_id_array() { 1755 $g1 = $this->factory->group->create(); 1756 $g2 = $this->factory->group->create( array( 1757 'parent_id' => $g1, 1758 ) ); 1759 $g3 = $this->factory->group->create( array( 1760 'parent_id' => $g2, 1761 ) ); 1762 $g4 = $this->factory->group->create(); 1763 1764 $groups = BP_Groups_Group::get( array( 1765 'parent_id' => array( $g1, $g2 ), 1766 ) ); 1767 1768 $found = wp_list_pluck( $groups['groups'], 'id' ); 1769 $this->assertEqualSets( array( $g2, $g3 ), $found ); 1770 } 1771 1772 /** 1773 * @group hierarchical_groups 1774 */ 1775 public function test_get_by_parent_id_comma_separated_string() { 1776 $g1 = $this->factory->group->create(); 1777 $g2 = $this->factory->group->create( array( 1778 'parent_id' => $g1, 1779 ) ); 1780 $g3 = $this->factory->group->create( array( 1781 'parent_id' => $g2, 1782 ) ); 1783 $g4 = $this->factory->group->create(); 1784 1785 $groups = BP_Groups_Group::get( array( 1786 'parent_id' => "$g1, $g2", 1787 ) ); 1788 1789 $found = wp_list_pluck( $groups['groups'], 'id' ); 1790 $this->assertEqualSets( array( $g2, $g3 ), $found ); 1791 } 1792 1793 /** 1794 * @group hierarchical_groups 1795 */ 1796 public function test_get_by_parent_id_top_level_groups() { 1797 $g1 = $this->factory->group->create(); 1798 $g2 = $this->factory->group->create( array( 1799 'parent_id' => $g1, 1800 ) ); 1801 $g3 = $this->factory->group->create( array( 1802 'parent_id' => $g2, 1803 ) ); 1804 $g4 = $this->factory->group->create(); 1805 1806 $groups = BP_Groups_Group::get( array( 1807 'parent_id' => 0, 1808 ) ); 1809 1810 $found = wp_list_pluck( $groups['groups'], 'id' ); 1811 $this->assertEqualSets( array( $g1, $g4 ), $found ); 1812 } 1813 1814 /** 1815 * @group hierarchical_groups 1816 */ 1817 public function test_get_by_parent_id_top_level_groups_using_false() { 1818 $g1 = $this->factory->group->create(); 1819 $g2 = $this->factory->group->create( array( 1820 'parent_id' => $g1, 1821 ) ); 1822 $g3 = $this->factory->group->create( array( 1823 'parent_id' => $g2, 1824 ) ); 1825 $g4 = $this->factory->group->create(); 1826 1827 $groups = BP_Groups_Group::get( array( 1828 'parent_id' => false, 1829 ) ); 1830 1831 $found = wp_list_pluck( $groups['groups'], 'id' ); 1832 $this->assertEqualSets( array( $g1, $g4 ), $found ); 1833 } 1708 1834 } 1709 1835
Note: See TracChangeset
for help on using the changeset viewer.