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 6695641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:14:47+00:00 2026-05-26T06:14:47+00:00

I have a class that access web services. It can optionally cache results. So

  • 0

I have a class that access web services. It can optionally cache results. So I want to write two test classes. The first one (Ws_Test) runs tests without caching. The second one (WsCached_Test) extends the first and runs the same tests but with cache enabled.

In theory that solves my problem, but when I run ‘all tests’ only the second test class (WsCached_Test) is run. Seems like PHPUnit assumes the class has already been completely tested when WsCached_Test is run.

class Ws_Test extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->ws = new Ws();
    }

    // lots of tests
}

class WsCached_Test extends Ws_Test
{
    public function setUp()
    {
        $this->ws = new Ws();
        $this->ws->setCacheResults(true);
    }

    // inherits lots of 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-05-26T06:14:47+00:00Added an answer on May 26, 2026 at 6:14 am

    I don’t know if this will solve the problem, but my first attempt at a fix would be to make the base class abstract and have two subclasses: WsCached_Test and WsUncached_Test.

    abstract class BaseWsTester extends PHPUnit_Framework_TestCase
    {
        public function setUp()
        {
            $this->ws = new Ws();
        }
    
        // lots of tests
    }
    
    class WsUncached_Test extends BaseWsTester
    {
        // inherits lots of tests
    }
    
    class WsCached_Test extends BaseWsTester
    {
        public function setUp()
        {
            parent::setUp();
            $this->ws->setCacheResults(true);
        }
    
        // inherits lots of tests
    }
    

    The name BaseWsTester is chosen to keep PHPUnit from thinking it’s a test case to be run, and its abstractness should help. If this doesn’t work, move setUp() down into each subclass and remove it from the base class.

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

Sidebar

Related Questions

D2.0 classes have a __monitor class property that gives access to the class object's
I have a C# singleton class that multiple classes use. Is access through Instance
We want to have a hosted C# web service in IIS that I can
I have certain PHP class methods that access external variables. These variables are not
I have a class 'Data' that uses a getter to access some array. If
I have class that represents users. Users are divided into two groups with different
I have class method that returns a list of employees that I can iterate
I have a class that I want to use to store properties for another
I currently have a web application project that also includes web services within the
I have a web service that is quite heavy on database access. It works

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.