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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:45:47+00:00 2026-05-24T05:45:47+00:00

I’ve implemented the mockiterator solution from http://www.davegardner.me.uk/blog/2011/03/04/mocking-iterator-with-phpunit/ by creating classes that extend the Zend_Test_PHPUnit_DatabaseTestCase

  • 0

I’ve implemented the mockiterator solution from http://www.davegardner.me.uk/blog/2011/03/04/mocking-iterator-with-phpunit/ by creating classes that extend the Zend_Test_PHPUnit_DatabaseTestCase and Zend_Test_PHPUnit_ControllerTestCase and dropping in the the method to each child class.

However, I also ended up adding a few tweaks along the way, but it is a pain to have to make the same changes in each class to prevent divergent behaviour.

Both of the Zend classes inherit directly from the PHPUnit_Framework_TestCase is there a way of easily inserting a class between the PHPUnit and Zend classes which does not involve modifying the Zend library code directly? I guess I’m looking for an easy way to do something like this:

+-- PHPUnit_Framework_TestCase
 |
 +-- My_PHPUnit_Framework_TestCase 
  |
  +-- Zend_Test_PHPUnit_ControllerTestCase
  +-- Zend_Test_PHPUnit_DatabaseTestCase

I guess, as an alternative, I could replicate the two Zend classes in my library – but again, there could be problems whenever the Zend framework is uploaded, requiring my library to be rewritten from the new Zend testcase classes.

  • 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-24T05:45:48+00:00Added an answer on May 24, 2026 at 5:45 am

    In PHP you have linear, single parent inheritance. Unfortunately, that means that you can’t insert a middle, proxy class without modifying the source of the Zend class.

    If necessary (say, you have something which needs to be a child of two different DO classes, for example), there are ways to fake multiple inheritance, however.

    Using, magic methods, for instance, you can create a multi-proxy:

    class MultiProxy
    {
        private $poxies;
    
        public function __construct( array $arr )
        {
            $this->proxies = $arr;
        }
    
        public function __get( $name )
        {
            foreach( $this->proxies as $proxy )
            {
                if( property_exists( $proxy, $name ) )
                {
                    try
                    {
                        return $proxy->$name
                    }
                    catch( Exception e )
                    {
                        // swallow it.
                    }
                }
            }
            trigger_error( "$name not found on $this" );
        }
    
        public function __set( $name, $val )
        {
            foreach( $this->proxies as $proxy )
            {
                if( property_exists( $proxy, $name ) )
                {
                    try
                    {
                        $proxy->$name = $val;
                    }
                    catch( Exception e )
                    {
                        // swallow it.
                    }
                }
            }
            trigger_error( "$name not found on $this" );
        }
    
        public function __call( $name, $args )
        {
            foreach( $this->proxies as $proxy )
            {
                $proxy = array( $proxy, $name );
                if( is_callable( $proxy ) )
                {
                    try
                    {
                        call_user_func_array( $proxy, $args );
                    }
                    catch( Exception e )
                    {
                        // swallow it.
                    }
                }
            }
            trigger_error( "$name not found on $this" );
        }
    
        public function __toString()
        {
            $ret = "[" . get_class( $this ) . '::{';
            foreach( $this->proxies as $proxy )
            {
                $ret .= get_class( $proxy ) . ',';
            }
            return substr( $ret, 0, -1 ) .'}]';
        }
    }
    
    // use:
    class Foo{ public $a = 'FOO'; }
    class Bar{ public function doSomething(){ echo 'YAY!'; } }
    class Baz{ public $a = 'BAZ'; public function doSomething(){ echo 'BAAAZ!'; } }
    
    $foo = new Foo();
    $bar = new Bar(); // drink!
    $baz = new Baz();
    
    $multi = new MultiProxy( array( $foo, $bar, $baz ) );
    $multi->a = 'MULTI!';
    echo $multi->a == $foo->a? 1:0;
    $multi->doSomething();// YAY!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.