assertEquals(1, ArrayFunctions::min($array)); $array = [5, 4, 3, 2, 1]; $this->assertEquals(1, ArrayFunctions::min($array)); // by default nulls are low, and should be returned as if they are the lowest value $array = [1, 2, 3, 4, 5, null]; $this->assertEquals(null, ArrayFunctions::min($array)); // if nulls are high, they should be skipped because they aren't the min $this->assertEquals(1, ArrayFunctions::min($array, true)); // if the array only contains a null value it should be returned either way $array = [null]; $this->assertEquals(null, ArrayFunctions::min($array)); $this->assertEquals(null, ArrayFunctions::min($array, true)); // should behave alphabetically for strings $array = ['a', 'b', 'c', 'd', 'e']; $this->assertEquals('a', ArrayFunctions::min($array)); $array = ['e', 'd', 'c', 'b', 'a']; $this->assertEquals('a', ArrayFunctions::min($array)); } public function testMax() { $array = [1, 2, 3, 4, 5]; $this->assertEquals(5, ArrayFunctions::max($array)); $array = [5, 4, 3, 2, 1]; $this->assertEquals(5, ArrayFunctions::max($array)); // by default nulls are low, and should be treated as if they are the lowest value $array = [1, 2, 3, 4, 5, null]; $this->assertEquals(5, ArrayFunctions::max($array)); // if nulls are high, they should be returned as if they are the highest value $this->assertEquals(null, ArrayFunctions::max($array, true)); // if the array only contains a null value it should be returned either way $array = [null]; $this->assertEquals(null, ArrayFunctions::max($array)); $this->assertEquals(null, ArrayFunctions::max($array, true)); // should behave alphabetically for strings $array = ['a', 'b', 'c', 'd', 'e']; $this->assertEquals('e', ArrayFunctions::max($array)); $array = ['e', 'd', 'c', 'b', 'a']; $this->assertEquals('e', ArrayFunctions::max($array)); } }