lithium\tests\cases\data\collection\DocumentSetTest::testPopulateResourceClose PHP Method

testPopulateResourceClose() public method

    public function testPopulateResourceClose()
    {
        $result = new MockResult(array('data' => array(array('_id' => '4c8f86167675abfabdbf0300', 'title' => 'bar'), array('_id' => '5c8f86167675abfabdbf0301', 'title' => 'foo'), array('_id' => '6c8f86167675abfabdbf0302', 'title' => 'dib'))));
        $doc = new DocumentSet(array('model' => $this->_model, 'result' => $result));
        $result = $doc->rewind();
        $this->assertInstanceOf('lithium\\data\\entity\\Document', $result);
        $this->assertInternalType('string', $result['_id']);
        $expected = array('_id' => '4c8f86167675abfabdbf0300', 'title' => 'bar');
        $this->assertEqual($expected, $result->data());
        $expected = array('_id' => '5c8f86167675abfabdbf0301', 'title' => 'foo');
        $this->assertEqual($expected, $doc->next()->data());
        $expected = array('_id' => '6c8f86167675abfabdbf0302', 'title' => 'dib');
        $result = $doc->next()->data();
        $this->assertEqual($expected, $result);
        $this->assertFalse($doc->next());
    }