lithium\tests\cases\data\source\DatabaseTest::testSimpleQueryRender PHP Method

testSimpleQueryRender() public method

    public function testSimpleQueryRender()
    {
        $fieldList = '{MockDatabasePost}.{id}, {MockDatabasePost}.{title},';
        $fieldList .= ' {MockDatabasePost}.{created}';
        $table = '{mock_database_posts} AS {MockDatabasePost}';
        $result = $this->_db->renderCommand(new Query(array('type' => 'read', 'model' => $this->_model, 'fields' => array('id', 'title', 'created'))));
        $this->assertEqual("SELECT {$fieldList} FROM {$table};", $result);
        $result = $this->_db->renderCommand(new Query(array('type' => 'read', 'model' => $this->_model, 'fields' => array('id', 'title', 'created'), 'limit' => 1)));
        $this->assertEqual("SELECT {$fieldList} FROM {$table} LIMIT 1;", $result);
        $result = $this->_db->renderCommand(new Query(array('type' => 'read', 'model' => $this->_model, 'fields' => array('id', 'title', 'created'), 'limit' => 1, 'conditions' => 'Post.id = 2')));
        $this->assertEqual("SELECT {$fieldList} FROM {$table} WHERE Post.id = 2 LIMIT 1;", $result);
    }
DatabaseTest