|
@@ 1931-1948 (lines=18) @@
|
| 1928 |
|
$this->assertEquals(0, count($terms)); |
| 1929 |
|
} |
| 1930 |
|
|
| 1931 |
|
public function test_hierarchical_true_with_child_of_should_return_grandchildren() |
| 1932 |
|
{ |
| 1933 |
|
$initial_terms = $this->create_hierarchical_terms(); |
| 1934 |
|
|
| 1935 |
|
// Case where hierarchical is true |
| 1936 |
|
$terms = get_terms( |
| 1937 |
|
'category', array( |
| 1938 |
|
'hierarchical' => true, |
| 1939 |
|
'child_of' => $initial_terms['one_term']['term_id'] |
| 1940 |
|
) |
| 1941 |
|
); |
| 1942 |
|
|
| 1943 |
|
$expected = array( |
| 1944 |
|
$initial_terms['two_term']['term_id'], |
| 1945 |
|
$initial_terms['three_term']['term_id'], |
| 1946 |
|
$initial_terms['five_term']['term_id'], |
| 1947 |
|
$initial_terms['six_term']['term_id'], |
| 1948 |
|
); |
| 1949 |
|
$actual = wp_list_pluck($terms, 'term_id'); |
| 1950 |
|
$this->assertEqualSets($expected, $actual); |
| 1951 |
|
} |
|
@@ 1953-1970 (lines=18) @@
|
| 1950 |
|
$this->assertEqualSets($expected, $actual); |
| 1951 |
|
} |
| 1952 |
|
|
| 1953 |
|
public function test_parent_should_override_child_of() |
| 1954 |
|
{ |
| 1955 |
|
$initial_terms = $this->create_hierarchical_terms(); |
| 1956 |
|
|
| 1957 |
|
$terms = get_terms( |
| 1958 |
|
'category', array( |
| 1959 |
|
'hide_empty' => false, |
| 1960 |
|
'child_of' => $initial_terms['one_term']['term_id'], |
| 1961 |
|
'parent' => $initial_terms['one_term']['term_id'] |
| 1962 |
|
) |
| 1963 |
|
); |
| 1964 |
|
|
| 1965 |
|
// Verify that parent takes precedence over child_of and returns only direct children. |
| 1966 |
|
$expected = array( |
| 1967 |
|
$initial_terms['two_term']['term_id'], |
| 1968 |
|
$initial_terms['five_term']['term_id'], |
| 1969 |
|
$initial_terms['seven_term']['term_id'] |
| 1970 |
|
); |
| 1971 |
|
$actual = wp_list_pluck($terms, 'term_id'); |
| 1972 |
|
$this->assertEqualSets($expected, $actual); |
| 1973 |
|
} |
|
@@ 2042-2059 (lines=18) @@
|
| 2039 |
|
/** |
| 2040 |
|
* @ticket 29185 |
| 2041 |
|
*/ |
| 2042 |
|
public function test_hierarchical_true_parent_overrides_child_of() |
| 2043 |
|
{ |
| 2044 |
|
$initial_terms = $this->create_hierarchical_terms(); |
| 2045 |
|
|
| 2046 |
|
// Case where hierarchical is true |
| 2047 |
|
$terms = get_terms( |
| 2048 |
|
'category', array( |
| 2049 |
|
'hierarchical' => true, |
| 2050 |
|
'child_of' => $initial_terms['one_term']['term_id'], |
| 2051 |
|
'parent' => $initial_terms['one_term']['term_id'], |
| 2052 |
|
) |
| 2053 |
|
); |
| 2054 |
|
|
| 2055 |
|
// Verify that parent takes precedence over child_of |
| 2056 |
|
$expected = array( |
| 2057 |
|
$initial_terms['two_term']['term_id'], |
| 2058 |
|
$initial_terms['five_term']['term_id'], |
| 2059 |
|
); |
| 2060 |
|
$actual = wp_list_pluck($terms, 'term_id'); |
| 2061 |
|
$this->assertEqualSets($expected, $actual); |
| 2062 |
|
} |