Alcaeus\MongoDbAdapter\Tests\Mongo\MongoCollectionTest::testSaveDuplicate PHP Method

testSaveDuplicate() public method

public testSaveDuplicate ( )
    public function testSaveDuplicate()
    {
        $collection = $this->getCollection();
        $collection->createIndex(['foo' => 1], ['unique' => true]);
        $document = ['foo' => 'bar'];
        $collection->save($document);
        $this->setExpectedException('MongoDuplicateKeyException');
        unset($document['_id']);
        $collection->save($document);
    }
MongoCollectionTest