public function testSharedInstace()
 {
     $this->assertFalse(DocumentStore::hasSharedInstance());
     $sharedInstance = DocumentStore::getSharedInstance();
     $this->assertInstanceOf('\\Matryoshka\\Model\\Wrapper\\Mongo\\Criteria\\Isolated\\DocumentStore', $sharedInstance);
     $this->assertTrue(DocumentStore::hasSharedInstance());
     DocumentStore::resetSharedInstance();
     $this->assertFalse(DocumentStore::hasSharedInstance());
     $sharedInstance = clone $sharedInstance;
     DocumentStore::setSharedInstance($sharedInstance);
     $this->assertTrue(DocumentStore::hasSharedInstance());
     $this->assertSame($sharedInstance, DocumentStore::getSharedInstance());
 }
 /**
  * @dataProvider getDeletableStatesDataProvider
  * @param string $state
  */
 public function testDelete($state)
 {
     $transaction = $this->createTransactionEntityAsset();
     $transaction->setState($state);
     $transaction->setHydrator(new TransactionHydrator());
     $criteria = new ActiveRecordCriteria();
     $expectedData = $this->exampleTransactionData;
     // Insert will inject _id into $expectedData
     DocumentStore::getSharedInstance()->isolatedUpsert($this->mockProxy, $expectedData);
     // Populate the object
     $this->transactionModel->getHydrator()->hydrate($expectedData, $transaction);
     $criteria->setId($transaction->getId());
     $expectedReturn = 1;
     $this->expectsFindById($expectedData['_id'], $expectedData, $this->at(0));
     $this->expectsRemove($expectedData, $this->at(1));
     $this->assertSame($expectedReturn, $this->transactionModel->delete($criteria));
 }
 public function setUp()
 {
     $this->traitObject = $this->getObjectForTrait('Matryoshka\\Model\\Wrapper\\Mongo\\Criteria\\Isolated\\DocumentStoreAwareTrait');
     $this->documentStore = DocumentStore::getSharedInstance();
 }
 /**
  * @param $id
  * @param array $document
  */
 protected function assertHasDocumentCache($id, array $document)
 {
     $this->assertTrue(DocumentStore::getSharedInstance()->has(self::$sharedDataGateway, $id));
     $this->assertSame($document, DocumentStore::getSharedInstance()->get(self::$sharedDataGateway, $id));
 }