Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

Today I came back to a project I have not touched for a while. It is a Zend Framework 2 project using MongoDB as its database.

I decided since it had been a while to update MongoDB to the latest version (2.4) from (2.0), and the driver to the latest (1.4.2?).

Now when running my PHPUnit tests I get errors due to a mocked MongoCollection class failing a "is_a()" test.

Instead of the new mocked class being an instance of MongoCollection, it turns out to be a _PHP_Incomplete_Class instance instead. I have been searching high and low and I cannot find anyone with the same issue. I can only assume something has changed to the MongoDB classes that PHPUnit doesn't like.

 $collection = $this->getMockBuilder('MongoCollection')
                    ->disableOriginalConstructor()
                    ->getMock();

When inspecting $collection I see:

_PHP_Incomplete_Class Object {
    _PHP_Incomplete_Class_Name => (string) Mock_MongoCollection_2798b1f7"
}

Does anyone know a way around this or do I need to bash out my own MongoCollection mock/test class to test with?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

OK, after a few days of doing other things I came back to this issue and have solved it.

I updated PHPUnit to the latest version (as of today, 1 August 2013) via PEAR and the issue has gone away.

The lesson: try updating everything and not just one component!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.