public function testLastIndexOf() { // from js $numbers = array(1, 0, 1, 0, 0, 1, 0, 0, 0); $this->assertEquals(5, __::lastIndexOf($numbers, 1), 'can computer lastIndexOf'); $this->assertEquals(8, __::lastIndexOf($numbers, 0), 'lastIndexOf the other element'); $this->assertEquals(-1, __::lastIndexOf(null, 2), 'handles nulls properly'); $func = function () { return __::lastIndexOf(func_get_args(), 1); }; $result = $func(1, 0, 1, 0, 0, 1, 0, 0, 0); $this->assertEquals(5, $result, 'works on an arguments object'); // extra $this->assertEquals(4, __(array('a', 'b', 'c', 'c', 'c', 'd'))->lastIndexOf('c'), 'works with OO-style calls'); $this->assertEquals('c', __(array('a' => 5, 'b' => 10, 'c' => 10))->lastIndexOf(10), 'works with associative arrays'); $this->assertEquals(2, __::lastIndexOf('foobar', 'o'), 'works with strings'); // docs $this->assertEquals(4, __::lastIndexOf(array(1, 2, 3, 2, 2), 2)); }
public function testLastIndexOf() { $object = array(5, 2, 2, 20); $return = 2; $result = __::lastIndexOf($object, 2); $this->assertEquals($return, $result); }