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

  • Home
  • SEARCH
  • 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 6788389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:28:48+00:00 2026-05-26T17:28:48+00:00

I need some advice on how I can proceed with this issue. Using PHP

  • 0

I need some advice on how I can proceed with this issue.

Using PHP
An example would be:

class BuilderClass {
 function getClass($id, $some, $vars){
  $dbResult = new db_Class::getDbRows($id, $some, $vars);
  foreach(...)
   // Build something from the database values

  return self;
 }
}

So what I want to do is to create a test case where I somehow mock the db results.

I have not found any great way to do this, please point me in the right direction or similar to get this working for me.

I could change something within the builder itself for example call a class that runs the function: FunctionRunner::runStaticFunction(“db_Class”, “getDbRows”, $args, $something_else); But at the moment I don’t know if that is possible neither. Any research articles that cover this or any sites that explain this. I’d appriciate anything at the moment.

Thanks
/Marcus

  • 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-05-26T17:28:49+00:00Added an answer on May 26, 2026 at 5:28 pm

    Split the operations of retrieving data from database, and building the data.

    class BuilderClass {
        function getClass($id, $some, $vars){
            $dbResult = new db_Class::getDbRows($id, $some, $vars);
            return doGetClass($dbResult);
        }
    
        function doGetClass($dbResult) {
            foreach(...)
             // Build something from the database values
    
            return self;   
        }
    }
    

    That way, you can test doGetClass in isolation from calling the database .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some advice from experts :) I will develop a website using PHP
I need some advice on how to model this simple categorization (?) example: I
I need some advice in tackling a query. I can handle this in a
I need some advice/help on this, I can't see the wood from the trees
I need some advice as to how I easily can separate test runs for
I need some advice here. I need to make a webservice, that can make
I need some advice. (For those who have already read this before I have
I just need some advice about using tags. I'm working on a website right
I'm running into kindof an annoying problem and would need some advice... Let's say
I need some advice on how I can change the implementation of some code.

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.