public function testStoreDocumentInPool_DocumentAlreadyStored()
{
/**
* Store document to pool
*/
$this->assertTrue($this->collection->isDocumentPoolEmpty());
$document = $this->collection->createDocument(array('param' => 'value'))->save();
$this->assertFalse($this->collection->isDocumentPoolEmpty());
/**
* Modify document in another thread
*/
$client = new Client(getenv('PHPMONGO_DSN') ? getenv('PHPMONGO_DSN') : null);
$client->getDatabase($document->getCollection()->getDatabase()->getName())->getCollection($document->getCollection()->getName())->find()->findOne()->set('param', 'updatedValue')->save();
// here oroginal document must be in unconsisted state
$this->assertEquals('value', $document->get('param'));
// overload document in pool with new data
$this->collection->find()->findOne();
$this->assertEquals('updatedValue', $document->get('param'));
}