public function testValues() { $map = ["one" => "a", "two" => "b", "three" => "c"]; $values = CMap::values($map); $this->assertTrue(CArray::equals($values, CArray::fromElements("a", "b", "c"))); }
public function testRepeat() { $array = CArray::repeat("a", 5); $this->assertTrue(CArray::equals($array, CArray::fromElements("a", "a", "a", "a", "a"))); }
/** * Determines if an array is equal to another array. * * For any two arrays to be equal, they need to have the same number of the same elements arranged in the same * order. * * You can use your own comparator for the comparison of the elements in the arrays, but the default comparator has * got you covered when comparing scalar values, such as `string`, `int`, `float`, and `bool`. And the default * comparator is smart enough to know how to compare objects of those classes that conform to the IEquality or * IEqualityAndOrder interface (static or not), including CUStringObject, CArrayObject, CMapObject, CTime etc. See * the [CComparator](CComparator.html) class for more on this. * * @param array $toArray The second array for comparison. * @param callable $comparator **OPTIONAL. Default is** `CComparator::EQUALITY`. The function or method to be * used for the comparison of any two elements. If this parameter is provided, the comparator should take two * parameters, with the first parameter being an element from *this* array and the second parameter being an * element from the second array, and return `true` if the two elements are equal and `false` otherwise. * * @return bool `true` if the two arrays are equal, `false` otherwise. * * @link CComparator.html CComparator */ public function equals($toArray, $comparator = CComparator::EQUALITY) { return CArray::equals($this->m_splArray, $toArray, $comparator); }