lithium\tests\cases\util\CollectionTest::testCount PHP Method

testCount() public method

public testCount ( )
    public function testCount()
    {
        $collection = new Collection(array('data' => array(5, 3, 4, 1, 2)));
        $this->assertIdentical(5, count($collection));
        $collection = new Collection(array('data' => array()));
        $this->assertIdentical(0, count($collection));
        $collection = new Collection(array('data' => array(5, null, 4, true, false, 'bob')));
        $this->assertIdentical(6, count($collection));
        unset($collection[1]);
        unset($collection[2]);
        $this->assertIdentical(4, count($collection));
        $first = (object) array('name' => 'First');
        $second = (object) array('name' => 'Second');
        $third = (object) array('name' => 'Third');
        $doc = new Collection(array('data' => array($first, $second, $third)));
        $this->assertInternalType('object', $doc[0]);
        $this->assertInternalType('object', $doc[1]);
        $this->assertInternalType('object', $doc[2]);
        $this->assertCount(3, $doc);
    }