Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7904237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:57:58+00:00 2026-06-03T09:57:58+00:00

I am trying TDD in Codeigniter and I’m stuck. I am using TOAST and

  • 0

I am trying TDD in Codeigniter and I’m stuck. I am using TOAST and want to test a simple feature without touching the database…

function test_get_products_by_user_id()
{
}

How to create a mock of the database for a case like this? I do not want to query the database for such tests.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:57:59+00:00Added an answer on June 3, 2026 at 9:57 am

    Even though I wanted to avoid querying a real database, the answer for this is to create a separate database and fill it with dummy data for testing. You can easily switch the database when running the tests – this is written in the documentation

    “The reason we use a multi-dimensional array rather than a more simple one is to permit you to optionally store multiple sets of connection values. If, for example, you run multiple environments (development, production, test, etc.) under a single installation, you can set up a connection group for each, then switch between groups as needed. For example, to set up a “test” environment you would do this:”

    $db['test']['hostname'] = "localhost";
    $db['test']['username'] = "root";
    $db['test']['password'] = "";
    $db['test']['database'] = "database_name";
    $db['test']['dbdriver'] = "mysql";
    $db['test']['dbprefix'] = "";
    $db['test']['pconnect'] = TRUE;
    $db['test']['db_debug'] = FALSE;
    $db['test']['cache_on'] = FALSE;
    $db['test']['cachedir'] = "";
    $db['test']['char_set'] = "utf8";
    $db['test']['dbcollat'] = "utf8_general_ci";
    $db['test']['swap_pre'] = "";
    $db['test']['autoinit'] = TRUE;
    $db['test']['stricton'] = FALSE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to re-write a method using TDD. Here is the original method
I'm developing a project using BDD/TDD techniques and I'm trying my best to stay
I'm trying to develop a extension ( IExtension<OperationContext> ) for System.ServiceModel.ObjectContext using TDD. The
I am trying out TDD and creating fake objects, I want to use XML
I'm trying to learn TDD by applying it to a simple project of mine.
I am trying to learn TDD/BDD using NUnit and Moq. The design that I
Am trying to get started using TDD on a class which spits out an
I am trying to learn and implement TDD specifically using Moq and I have
I was trying to TDD using SubSonic 2.1, MySQL and C# and when I
I trying to learn tdd using RSpec. I took this example from a cheat

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.