AmericanCouncils/AyamelResourceApiServer — pull request #171 by evillemez (2014-03-28 22:42:42+00:00)
Title: Search tests... probably?

Theoretically, this will make the current search tests pass - but I ran into weirdness and ran out of time tracking it down:

I think that when models are generated some fields may be being set to null magically. The case is this:

In tests where models were fetched after the fixtures were built, the `ResourceIndexer` will die on line 197. Theoretically this should be impossible - the field is initialized in the constructor, and if set to null via `Resource::setRelations(null)` - will be reinitialized to an empty `ArrayCollection`.

My theory is this:

During fixture generation, somehow it's set to null. Doctrine's DocumentManager persists the fixtures, but on subsequent retrievals the DocumentManager doesn't actually query the database and rebuild the object, because it returns the fixture instance it persisted previously. I know that when Doctrine is clean (meaning, it actually fetches and builds an instance its self), it must work because other tests with the `ResourceIndexer` pass as expected.

I started an issue in WebServicesBundle - but it's just a hunch.

https://github.com/AmericanCouncils/WebServicesBundle/issues/34