public function testIsolatedRemoveShouldThrowDocumentModifiedException()
 {
     $testData = ['test' => 'test'];
     $options = ['w' => 1];
     //ensure document
     $this->mongoCollectionMock->expects($this->atLeastOnce())->method('insert')->with($this->equalTo($testData), $this->equalTo($options))->will($this->returnValue(['ok' => true, 'n' => 0]));
     // MongoDB returns 0 on insert operation
     $this->assertEquals(1, $this->documentStore->isolatedUpsert($this->mongoCollection, $testData, $options));
     $this->mongoCollectionMock->expects($this->atLeastOnce())->method('remove')->with($this->equalTo($testData))->will($this->returnValue(['ok' => true, 'n' => 0]));
     $this->setExpectedException('\\Matryoshka\\Model\\Wrapper\\Mongo\\Exception\\DocumentModifiedException');
     $this->assertEquals(1, $this->documentStore->isolatedRemove($this->mongoCollection, $testData['_id'], $options));
 }
 /**
  * @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));
 }