lithium\tests\cases\data\collection\RecordSetTest::testRecordSet PHP Method

testRecordSet() public method

public testRecordSet ( )
    public function testRecordSet()
    {
        $expected = array('post1' => array('title' => 'My First Post', 'content' => 'First Content...'), 'post2' => array('title' => 'My Second Post', 'content' => 'Also some foobar text'), 'post3' => array('title' => 'My Third Post', 'content' => 'I like to write some foobar foo too'));
        $posts = new MockRecordSet(array('data' => $expected));
        $this->assertCount(3, $posts->get('_data'));
        $this->assertEqual($expected['post1'], $posts->first());
        $this->assertEqual($expected['post1'], $posts->current());
        $this->assertEqual($expected['post2'], $posts->next());
        $this->assertEqual($expected['post2'], $posts->current());
        $this->assertEqual($expected['post1'], $posts->prev());
        $this->assertEqual($expected['post2'], $posts->next());
        $this->assertEqual($expected['post3'], $posts->next());
        $this->assertEqual($expected['post3'], $posts->current());
        $this->assertEqual($expected['post2'], $posts->prev());
        $this->assertEqual($expected['post1'], $posts->rewind());
        $this->assertEqual($expected['post1'], $posts->current());
        $this->assertEqual($expected['post1'], $posts['post1']);
        $posts = new MockRecordSet();
        $posts->set($expected);
        $this->assertCount(3, $posts->get('_data'));
        $this->assertEqual($expected['post1'], $posts->first());
        $this->assertEqual($expected['post1'], $posts->current());
        $this->assertEqual($expected['post2'], $posts->next());
        $this->assertEqual($expected['post2'], $posts->current());
        $this->assertEqual($expected['post1'], $posts->prev());
        $this->assertEqual($expected['post2'], $posts->next());
        $this->assertEqual($expected['post3'], $posts->next());
        $this->assertEqual($expected['post3'], $posts->current());
        $this->assertEqual($expected['post2'], $posts->prev());
        $this->assertEqual($expected['post1'], $posts->rewind());
        $this->assertEqual($expected['post1'], $posts->current());
        $this->assertEqual($expected['post1'], $posts['post1']);
    }