コード例 #1
0
 /**
  * Tests locale_translation_clear_cache_projects().
  */
 public function testLocaleTranslationClearCacheProjects()
 {
     $this->moduleHandler->loadInclude('locale', 'inc', 'locale.translation');
     $expected = [];
     $this->assertIdentical($expected, locale_translation_get_projects());
     $this->projectStorage->set('foo', []);
     $expected['foo'] = new \stdClass();
     $this->assertEqual($expected, locale_translation_get_projects());
     $this->projectStorage->set('bar', []);
     locale_translation_clear_cache_projects();
     $expected['bar'] = new \stdClass();
     $this->assertEqual($expected, locale_translation_get_projects());
 }
コード例 #2
0
ファイル: LocaleUpdateTest.php プロジェクト: shumer/blog
 /**
  * Tests automatic translation import when a module is enabled.
  */
 public function testEnableUninstallModule()
 {
     // Make the hidden test modules look like a normal custom module.
     \Drupal::state()->set('locale.test_system_info_alter', TRUE);
     // Check if there is no translation yet.
     $this->assertTranslation('Tuesday', '', 'de');
     // Enable a module.
     $edit = array('modules[Testing][locale_test_translate][enable]' => 'locale_test_translate');
     $this->drupalPostForm('admin/modules', $edit, t('Save configuration'));
     // Check if translations have been imported.
     $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 7, '%update' => 0, '%delete' => 0)), 'One translation file imported.');
     $this->assertTranslation('Tuesday', 'Dienstag', 'de');
     $edit = array('uninstall[locale_test_translate]' => 1);
     $this->drupalPostForm('admin/modules/uninstall', $edit, t('Uninstall'));
     $this->drupalPostForm(NULL, array(), t('Uninstall'));
     // Check if the file data is removed from the database.
     $history = locale_translation_get_file_history();
     $this->assertFalse(isset($history['locale_test_translate']), 'Project removed from the file history');
     $projects = locale_translation_get_projects();
     $this->assertFalse(isset($projects['locale_test_translate']), 'Project removed from the project list');
 }