phpstreams\tests\unit\StreamTest::testAll PHP Method

testAll() public method

public testAll ( )
    public function testAll()
    {
        $stream = new Stream([1, 4, 9, 16, 25]);
        // All these integers are truthy.
        $this->assertTrue($stream->all());
        // Not all of them are even.
        $this->assertFalse($stream->all(function ($value) {
            return $value % 2 == 0;
        }));
        // All of these are squares.
        $this->assertTrue($stream->all(function ($value) {
            $root = round(sqrt($value));
            return $root * $root == $value;
        }));
    }