public function testGetDocumentsFromDocumentPool() { $document1 = $this->collection->createDocument(array('field' => 'value1'))->save(); $document2 = $this->collection->createDocument(array('field' => 'value2'))->save(); $this->assertEquals(2, $this->collection->documentPoolCount()); // without arguments $documents = $this->collection->getDocumentsFromDocumentPool(); $this->assertEquals(2, count($documents)); $this->assertArrayHasKey((string) $document1->getId(), $documents); $this->assertArrayHasKey((string) $document2->getId(), $documents); // with arguments $documents = $this->collection->getDocumentsFromDocumentPool(array($document1->getId())); $this->assertEquals(1, count($documents)); $this->assertArrayHasKey((string) $document1->getId(), $documents); }
public function testGetDocuments_AllFromPool() { $doc1Id = new \MongoId(); $doc2Id = new \MongoId(); $doc3Id = new \MongoId(); // add documents skipping document pool $this->collection->batchInsert(array(array('_id' => $doc1Id, 'param' => 'value1'), array('_id' => $doc2Id, 'param' => 'value2'), array('_id' => $doc3Id, 'param' => 'value3'))); // load documents to document pool $doc1 = $this->collection->getDocument($doc1Id); $this->assertEquals('value1', $doc1->param); $doc2 = $this->collection->getDocument($doc2Id); $this->assertEquals('value2', $doc2->param); $doc3 = $this->collection->getDocument($doc3Id); $this->assertEquals('value3', $doc3->param); $this->assertEquals(3, $this->collection->documentPoolCount()); // load all documents $documents = $this->collection->getDocuments(array($doc1Id, $doc2Id, $doc3Id)); $this->assertArrayHasKey((string) $doc1Id, $documents); $this->assertArrayHasKey((string) $doc2Id, $documents); $this->assertArrayHasKey((string) $doc3Id, $documents); }