Elgg\Structs\Collection\InMemoryTest::testIsMappable PHP Method

testIsMappable() public method

public testIsMappable ( )
    public function testIsMappable()
    {
        $collection = InMemory::fromArray([0, 1, 2, 3, 4]);
        $mapped = $collection->map(function ($number) {
            return $number * 2;
        });
        $this->assertTrue($mapped->contains(0));
        $this->assertTrue($mapped->contains(2));
        $this->assertTrue($mapped->contains(4));
        $this->assertTrue($mapped->contains(6));
        $this->assertTrue($mapped->contains(8));
        $this->assertEquals(5, count($mapped));
        $this->assertNotSame($mapped, $collection);
    }