Hi, indeed. I've had difficulties in running the PHPUnit tests, but have struggled on the issue within my app long enough to have a clear scenario.
Consider the following unit test:
Data has been inserted according to the code before $this->dm->clear();
Now, in a new PHP instance (web req or CLI proc) (to avoid taking any risk related to the reliability of DocumentManager::clear() and make sure objects are freshly hydrated ),
The follow assertion should be OK (I would expect it to be in the test, as it represents the purpose of the discriminator map):
$document = $this->dm->findOne('Documents\Project', array('name' => 'Sub Project'));
Now, suppose $id is the identifier value of $document as returned by the former code.
The following assertion should be also true:
$document = $this->dm->find('Documents\Project', $id);
This former test would fail in my case (doc class is Documents\Project as queried).
To me, the purpose of single inheritance is when we don't know by advance the class of the object that hydration will yield. The query is made on a common document class, and the class of each returned document will depend on the discriminator field.
In a typical application, these classes would implement a common interface. Having the possibility to isolate the implementation (concrete class) from the query is a key feature to benefit from the schema-less character of a NoSQL DB.
Am I right, or missing something?