Пример #1
0
int main() {

    bool nothingFailed = true;
    Test model;

    std::cout << SQL_PATH TEST_PATH BASIC_SQL << std::endl;
    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try to create the tables ... " ,
        model.import_sql_file(
          SQL_PATH TEST_PATH BASIC_SQL
        ),
        nothingFailed
    );


    CPPCMSSKEL_TEST_RESULT_WORK(
        "if username AND password are correct => true ... " ,
        model.test_both_ok(),
        nothingFailed
    );

    CPPCMSSKEL_TEST_RESULT_NOT_WORK(
        "If both are not correct => false ... " ,
        model.test_both_wrong(),
        nothingFailed
    );

    CPPCMSSKEL_TEST_RESULT_NOT_WORK(
        "If only username is correct => false ... " ,
        model.test_only_username_ok(),
        nothingFailed
    );

    CPPCMSSKEL_TEST_RESULT_NOT_WORK(
        "If only password is correct => false ... " ,
        model.test_only_password_ok(),
        nothingFailed
    );






    if (nothingFailed) {
        return 0;
    } else {
        return 1;
    }
}
Пример #2
0
int main() {

    bool nothingFailed = true;
    Test model;

    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try to create the tables ... " ,
        model.import_sql_file(
          SQL_PATH TEST_PATH BASIC_SQL
        ),
        nothingFailed
    );


    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try to check if we can retrieve whole user by its id ... " ,
        model.test_work(),
        nothingFailed
    );

    CPPCMSSKEL_TEST_RESULT_NOT_WORK(
        "Try to check if retreiving a user with a non existing id give a non existing user ... " ,
        model.test_not_work(),
        nothingFailed
    );


    if (nothingFailed) {
        return 0;
    } else {
        return 1;
    }
}
Пример #3
0
int main() {

    bool nothingFailed = true;
    TestModel model;

    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try to create the tables ... " ,
        model.import_sql_file(
            SQL_PATH TEST_PATH BASIC_SQL
        ),
        nothingFailed
    );


    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try to check the existence of an existing record ... " ,
        model.test(),
        nothingFailed
    );

    CPPCMSSKEL_TEST_RESULT_NOT_WORK(
        "Try to check the existence of a non-existing record ... " ,
        model.test_not_work(),
        nothingFailed
    );


    if (nothingFailed) {
        return 0;
    } else {
        return 1;
    }
}
Пример #4
0
int main() {

    bool nothingFailed = true;
    Test model;

    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try to create the tables ... " ,
        model.import_sql_file(
          SQL_PATH TEST_PATH BASIC_SQL
        ),
        nothingFailed
    );


    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try to check if we know that the admin is admin ... " ,
        model.test_work(),
        nothingFailed
    );

    CPPCMSSKEL_TEST_RESULT_NOT_WORK(
        "Try to check if we know an normal user is not admin ... " ,
        model.test_not_work(),
        nothingFailed
    );


    if (nothingFailed) {
        return 0;
    } else {
        return 1;
    }
}
Пример #5
0
int main() {


    bool noTestFailed = true;
    models::Articles articlesModels(TEST_NAME ".db");

    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try load the database ... " ,
        articlesModels.import_sql_file(DB_SQL_FILE_PATH),
        noTestFailed
    );
    
    // we first load some raw articles on the database
    CPPCMSSKEL_TEST_RESULT_WORK(
        "Try to load the database with some data ... " ,
        articlesModels.import_sql_file(SQL_FILL_ARTICLES),
        noTestFailed
    );
    
    // load them again should not work as it will not met
    // the unique(lang,slug) constraint 
    CPPCMSSKEL_TEST_RESULT_NOT_WORK(
        "Load them again should not work ... " ,
        articlesModels.import_sql_file(SQL_FILL_ARTICLES),
        noTestFailed
    );
 
    
    // now we check if we can retrieve an article
    std::cout << "We try to get an article using get_from_lang_slug  ... ";
    results::Article firstArticle = articlesModels.get_from_lang_and_slug(
        "fr",
        "page_principale"
    );
    if ((!firstArticle.exists())) {
        noTestFailed = false;
        std::cout << " [fail]" << std::endl; 
    } else {
        std::cout << " [ok]" << std::endl; 
    }
    // now if we try to get an article with the id of the previous one
    // we should get (of course) the same one
    std::cout << "Using get_from_id to retrieve the same article ... ";
    results::Article secondArticle = articlesModels.get_from_id(
        firstArticle.id
    );
    if (
       !secondArticle.exists() ||
       secondArticle.id != firstArticle.id ||
       secondArticle.slug.compare(firstArticle.slug) != 0 ||
       secondArticle.lang.compare(firstArticle.lang) != 0
    ) {
        noTestFailed = false;
        std::cout << " [fail]" << std::endl; 
    } else {
        std::cout << " [ok]" << std::endl; 
    }

    
    if (noTestFailed) {
        return 0;
    } else {
        return 1;
    }


}