LocaleTranslatedSchemaDefinitionTest.php in Zircon Profile 8.0
File
core/modules/locale/src/Tests/LocaleTranslatedSchemaDefinitionTest.php
View source
<?php
namespace Drupal\locale\Tests;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\simpletest\WebTestBase;
class LocaleTranslatedSchemaDefinitionTest extends WebTestBase {
public static $modules = array(
'language',
'locale',
'node',
);
protected function setUp() {
parent::setUp();
ConfigurableLanguage::createFromLangcode('fr')
->save();
$this
->config('system.site')
->set('default_langcode', 'fr')
->save();
\Drupal::service('entity.definition_update_manager')
->applyUpdates();
drupal_flush_all_caches();
}
function testTranslatedSchemaDefinition() {
$stringStorage = \Drupal::service('locale.storage');
$source = $stringStorage
->createString(array(
'source' => 'The node ID.',
))
->save();
$stringStorage
->createTranslation(array(
'lid' => $source->lid,
'language' => 'fr',
'translation' => 'Translated node ID',
))
->save();
$this
->assertEqual('Translated node ID', \Drupal::entityManager()
->getBaseFieldDefinitions('node')['nid']
->getDescription());
$this
->assertFalse(\Drupal::service('entity.definition_update_manager')
->needsUpdates());
}
function testTranslatedUpdate() {
$user = $this
->drupalCreateUser(array(
'administer software updates',
));
$this
->drupalLogin($user);
$update_url = $GLOBALS['base_url'] . '/update.php';
$this
->drupalGet($update_url, array(
'external' => TRUE,
));
$stringStorage = \Drupal::service('locale.storage');
$sources = $stringStorage
->getStrings();
foreach ($sources as $source) {
$stringStorage
->createTranslation(array(
'lid' => $source->lid,
'language' => 'fr',
'translation' => $this
->randomMachineName(100),
))
->save();
}
$this
->drupalGet($update_url . '/selection', array(
'external' => TRUE,
));
$this
->assertRaw('messages--status', 'No pending updates.');
$this
->assertNoLinkByHref('fr/update.php/run', 'No link to run updates.');
}
}