Commit 5145112c authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-414: Remove orphan chunks for GridFS spec tests

parent a16c1884
...@@ -6,6 +6,7 @@ use MongoDB\Collection; ...@@ -6,6 +6,7 @@ use MongoDB\Collection;
use MongoDB\BSON\Binary; use MongoDB\BSON\Binary;
use MongoDB\BSON\ObjectId; use MongoDB\BSON\ObjectId;
use MongoDB\BSON\UTCDateTime; use MongoDB\BSON\UTCDateTime;
use MongoDB\GridFS\Exception\FileNotFoundException;
use MongoDB\Operation\BulkWrite; use MongoDB\Operation\BulkWrite;
use DateTime; use DateTime;
use Exception; use Exception;
...@@ -54,6 +55,15 @@ class SpecFunctionalTest extends FunctionalTestCase ...@@ -54,6 +55,15 @@ class SpecFunctionalTest extends FunctionalTestCase
$result = $e; $result = $e;
} }
/* Per the GridFS spec: "Drivers MAY attempt to delete any orphaned
* chunks with files_id equal to id before raising the error." The spec
* tests do not expect orphaned chunks to be removed, so we manually
* remove those chunks from the expected collection. */
if ($test['act']['operation'] === 'delete' && $result instanceof FileNotFoundException) {
$filesId = $this->convertTypes($test['act'])['arguments']['id'];
$this->expectedChunksCollection->deleteMany(['files_id' => $filesId]);
}
if (isset($test['assert'])) { if (isset($test['assert'])) {
$this->executeAssert($test['assert'], $result); $this->executeAssert($test['assert'], $result);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment