Question

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?

Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top