/**
  * Provided modelClassName, $indexMetadata it generated index definitions that match schema requirements
  * @param string $modelClassName
  * @param array $indexesMetadata
  * @param $messageLogger
  * @return array index rules
  * @throws CException if we were unable to resolve an index
  */
 public static function resolve($modelClassName, array $indexesMetadata, &$messageLogger)
 {
     $messageLogger->addInfoMessage(Zurmo::t('Core', 'Building Indexes definitions for {{model}}', array('{{model}}' => $modelClassName)));
     $indexes = array();
     foreach ($indexesMetadata as $indexName => $indexMetadata) {
         $indexResolved = RedBeanModelMemberIndexMetadataAdapter::resolve($indexMetadata);
         if ($indexResolved) {
             $indexes[$indexName] = $indexMetadata;
         } else {
             $errorMessage = Zurmo::t('Core', 'Failed to resolve {{model}}.{{index}} index', array('{{model}}' => $modelClassName, '{{index}}' => $indexName));
             $messageLogger->addErrorMessage($errorMessage);
             throw new CException($errorMessage);
         }
     }
     $messageLogger->addInfoMessage(Zurmo::t('Core', 'Index definitions Built'));
     return $indexes;
 }
 /**
  * @depends testResolveWithUniqueNotSet
  */
 public function testResolve()
 {
     $indexMetadata = array('members' => array('memberOne', 'memberTwo'), 'unique' => true);
     $resolved = RedBeanModelMemberIndexMetadataAdapter::resolve($indexMetadata);
     $this->assertTrue($resolved);
     $this->assertNotEmpty($indexMetadata);
     $this->assertArrayHasKey('columns', $indexMetadata);
     $this->assertCount(2, $indexMetadata['columns']);
     $this->assertEquals('memberone', $indexMetadata['columns'][0]);
     $this->assertEquals('membertwo', $indexMetadata['columns'][1]);
     $this->assertArrayHasKey('unique', $indexMetadata);
     $this->assertTrue($indexMetadata['unique']);
 }