The original documentation examples all used an "inventory" collection within the database under test. As such, DocumentationExamplesTest::getCollectionName() was overridden to return "inventory" and allow the setUp and tearDown methods to clean up the collection contents after each test case.
Later examples switched to using different collection and database names, which may no longer be cleaned up. Ideally, we should revise these examples to use the database under test whenever possible. The transaction examples will remain a notable exception, since they intentionally execute operations on different databases.
At the very least, we should ensure that collection data is cleaned up after each test. This can be done by creating an internal utility method to register namespaces, which will then be dropped during tearDown(). Alternatively, we can cook up something using event monitoring to track all namespaces utilized during a test, which might prove useful elsewhere in the test suite.
- related to
-
PHPLIB-400 Track collections used during tests to explicitly drop them in tearDown()
- Backlog