public function testModuleFormToMetadataAdapter()
 {
     $metadata = TestModule::getMetadata();
     $this->assertEquals(1, $metadata['global']['a']);
     $this->assertEquals(2, $metadata['global']['b']);
     $this->assertEquals(3, $metadata['global']['c']);
     $module = new TestModule(null, null);
     $moduleForm = new TestModuleForm();
     $moduleForm->a = 5;
     $moduleForm->b = 6;
     $moduleForm->c = 7;
     $moduleForm->singularModuleLabels = array('en' => 'texs', 'es' => 'texs', 'it' => 'texs', 'fr' => 'texs', 'de' => 'texs');
     $moduleForm->pluralModuleLabels = array('en' => 'texst', 'es' => 'texst', 'it' => 'texst', 'fr' => 'texst', 'de' => 'texst');
     $adapter = new ModuleFormToMetadataAdapter($module, $moduleForm);
     $adapter->setMetadata();
     $metadata = $module::getMetadata();
     $this->assertEquals(5, $metadata['global']['a']);
     $this->assertEquals(6, $metadata['global']['b']);
     $this->assertEquals(7, $metadata['global']['c']);
     $singularCompareData = array('en' => 'texs', 'es' => 'texs', 'it' => 'texs', 'fr' => 'texs', 'de' => 'texs');
     $this->assertEquals($singularCompareData, $metadata['global']['singularModuleLabels']);
     $pluralCompareData = array('en' => 'texst', 'es' => 'texst', 'it' => 'texst', 'fr' => 'texst', 'de' => 'texst');
     $this->assertEquals($pluralCompareData, $metadata['global']['pluralModuleLabels']);
 }
示例#2
0
 public function testGetModuleLabelByTypeAndLanguage()
 {
     $this->assertEquals('en', Yii::app()->languageHelper->getForCurrentUser());
     $this->assertEquals('Tes', TestModule::getModuleLabelByTypeAndLanguage('Singular'));
     $this->assertEquals('Test', TestModule::getModuleLabelByTypeAndLanguage('Plural'));
     $this->assertEquals('tes', TestModule::getModuleLabelByTypeAndLanguage('SingularLowerCase'));
     $this->assertEquals('test', TestModule::getModuleLabelByTypeAndLanguage('PluralLowerCase'));
     $metadata = TestModule::getMetadata();
     $metadata['global']['singularModuleLabels'] = array('en' => 'company', 'de' => 'gesellschaft');
     $metadata['global']['pluralModuleLabels'] = array('en' => 'companies', 'de' => 'gesellschaften');
     TestModule::setMetadata($metadata);
     $this->assertEquals('Company', TestModule::getModuleLabelByTypeAndLanguage('Singular'));
     $this->assertEquals('Companies', TestModule::getModuleLabelByTypeAndLanguage('Plural'));
     $this->assertEquals('company', TestModule::getModuleLabelByTypeAndLanguage('SingularLowerCase'));
     $this->assertEquals('companies', TestModule::getModuleLabelByTypeAndLanguage('PluralLowerCase'));
     Yii::app()->language = 'de';
     $this->assertEquals('Gesellschaft', TestModule::getModuleLabelByTypeAndLanguage('Singular'));
     $this->assertEquals('Gesellschaften', TestModule::getModuleLabelByTypeAndLanguage('Plural'));
     $this->assertEquals('gesellschaft', TestModule::getModuleLabelByTypeAndLanguage('SingularLowerCase'));
     $this->assertEquals('gesellschaften', TestModule::getModuleLabelByTypeAndLanguage('PluralLowerCase'));
     Yii::app()->language = 'en';
     //Demonstrate getSingularModuleLabel and getPluralModuleLabel and how if they are not overriden, they
     //will not necessarily produce desired results.
     $this->assertEquals('Zurmo', ZurmoModule::getModuleLabelByTypeAndLanguage('Singular'));
     $this->assertEquals('Zurmo', ZurmoModule::getModuleLabelByTypeAndLanguage('Plural'));
 }