public function testMongoStoreEnsureIndexesInCollection_LexProject_Ok() { // setup self::$environ = new LexiconMongoTestEnvironment(); self::$environ->clean(); $user1Id = self::$environ->createUser("user1name", "User1 Name", "*****@*****.**"); $user1 = new UserModel($user1Id); $srProject = null; $projectId = ProjectCommands::createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE, LexProjectModel::LEXICON_APP, $user1->id->asString(), self::$environ->website, $srProject); $project = new LexProjectModel($projectId); $databaseName = $project->databaseName(); $collectionName = LexEntryModel::mapper($databaseName)->getCollectionName(); $indexes = LexEntryModel::mapper($databaseName)->INDEXES_REQUIRED; foreach ($indexes as $index) { $this->assertTrue(MongoStore::isIndexIdenticalInCollection($index, $databaseName, $collectionName), 'index not in lexicon: ' . var_export($index, true)); } $additionalIndex = ['key' => ['test' => 1]]; $indexes[] = $additionalIndex; $this->assertFalse(MongoStore::isAllIndexFieldNamesInCollection($additionalIndex, $databaseName, $collectionName)); MongoStore::ensureIndexesInCollection($databaseName, $collectionName, $indexes); foreach ($indexes as $index) { $this->assertTrue(MongoStore::isIndexIdenticalInCollection($index, $databaseName, $collectionName), 'index not in lexicon: ' . var_export($index, true)); } }