Functional\Tests\LastTest::test PHP Method

test() public method

public test ( )
    public function test()
    {
        $fn = function ($v, $k, $collection) {
            InvalidArgumentException::assertCollection($collection, __FUNCTION__, 1);
            return $v == 'first' && $k == 0 || $v == 'third' && $k == 2;
        };
        $this->assertSame('third', last($this->list, $fn));
        $this->assertSame('third', last($this->listIterator, $fn));
        $this->assertNull(last($this->badArray, $fn));
        $this->assertNull(last($this->badIterator, $fn));
    }