Abstract class with abstract constructor wont work with getMockForAbstractClass #80

jaysonsantos opened this Issue Feb 4, 2012 · 4 comments

3 participants


Hi, I don't know if this a bug, however I tried a lot of things reading the docs I couldn't get this working.

abstract class Foo
    abstract public function __construct();

class FooTest extends PHPUnit_Framework_TestCase
    public function setUp()
        $this->object = $this->getMockForAbstractClass('Foo');

    public function testNothing()

I tried to pass parameter to not call the class constructor and tried to mock the __construct and didn't get it working.
Here is the report.

$ phpunit bug.php 
PHPUnit 3.6.9 by Sebastian Bergmann.

PHP Fatal error:  Class Mock_Foo_bdbb3933 contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Foo::__construct) in /usr/lib/php/pear/PHPUnit/Framework/MockObject/Generator.php(218) : eval()'d code on line 56

This was fixed in #73


Thanks @drak for pointing it out

@edorian edorian closed this Mar 1, 2012
@edorian edorian reopened this Apr 17, 2012

#73 was reverted for reasons stated there so this is open again


Dear contributor,

let me start by apologizing for not commenting and/or working on the issue you have reported or merging the pull request you have sent sooner.

PHPUnit 5.0 was released today. And today I am closing all open bug reports and pull requests for PHPUnit and its dependencies that I maintain. Please do not interpret the closing of this ticket as an insult or a lack of interest in your problem. I am sorry for any inconvenience this may cause.

If the topic of this ticket is still relevant then please open a new ticket or send a new pull request. If your ticket or pull request is about a defect then please check whether the issue still exists in PHPUnit 4.8 (which will received bug fixes until August 2016). If your ticket or pull request is about a new feature then please port your patch PHPUnit 5.0 before sending a new pull request.

I hope that today's extreme backlog grooming will allow me to respond to bug reports and pull requests in a more timely manner in the future.

Thank you for your understanding,

@sebastianbergmann sebastianbergmann locked and limited conversation to collaborators Oct 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.