Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -33,7 +33,7 @@ function config_translation_test_entity_type_alter(array &$entity_types) {
function config_translation_test_config_translation_info_alter(&$info) {
if (\Drupal::state()->get('config_translation_test_config_translation_info_alter')) {
// Limit account settings config files to only one of them.
$info['entity.user.admin_form']['names'] = array('user.settings');
$info['entity.user.admin_form']['names'] = ['user.settings'];
// Add one more config file to the site information page.
$info['system.site_information_settings']['names'][] = 'system.rss';

View file

@ -0,0 +1,58 @@
<?php
namespace Drupal\Tests\config_translation\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the content translation behaviours on date formats.
*
* @group config_translation
*/
class ConfigTranslationDateFormatUiTest extends BrowserTestBase {
public static $modules = [
'language',
'config_translation',
'system'
];
protected function setUp() {
parent::setUp();
// Enable additional languages.
$langcodes = ['de', 'es'];
foreach ($langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)->save();
}
$user = $this->drupalCreateUser([
'administer site configuration',
'translate configuration',
]);
$this->drupalLogin($user);
}
/**
* Tests date format translation behaviour.
*/
public function testDateFormatUI() {
$this->drupalGet('admin/config/regional/date-time');
// Assert translation link unlocked date format.
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium/translate');
// Assert translation link locked date format.
$this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_datetime/translate');
// Date pattern is visible on unlocked date formats.
$this->drupalGet('admin/config/regional/date-time/formats/manage/medium/translate/de/add');
$this->assertField('translation[config_names][core.date_format.medium][pattern]');
// Date pattern is not visible on locked date formats.
$this->drupalGet('admin/config/regional/date-time/formats/manage/html_datetime/translate/es/add');
$this->assertNoField('translation[config_names][core.date_format.html_datetime][pattern]');
}
}

View file

@ -0,0 +1,504 @@
<?php
namespace Drupal\Tests\config_translation\Functional;
use Drupal\block_content\Entity\BlockContentType;
use Drupal\Component\Utility\Unicode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
use Drupal\shortcut\Entity\ShortcutSet;
use Drupal\contact\Entity\ContactForm;
use Drupal\filter\Entity\FilterFormat;
use Drupal\taxonomy\Entity\Vocabulary;
/**
* Visit all lists.
*
* @group config_translation
* @see \Drupal\config_translation\Tests\ConfigTranslationViewListUiTest
*/
class ConfigTranslationListUiTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = [
'block',
'config_translation',
'contact',
'block_content',
'field',
'field_ui',
'menu_ui',
'node',
'shortcut',
'taxonomy',
'image',
'responsive_image',
'toolbar',
];
/**
* Admin user with all needed permissions.
*
* @var \Drupal\user\Entity\User
*/
protected $adminUser;
protected function setUp() {
parent::setUp();
$permissions = [
'access site-wide contact form',
'administer blocks',
'administer contact forms',
'administer content types',
'administer block_content fields',
'administer filters',
'administer menu',
'administer node fields',
'administer permissions',
'administer shortcuts',
'administer site configuration',
'administer taxonomy',
'administer account settings',
'administer languages',
'administer image styles',
'administer responsive images',
'translate configuration',
];
// Create and log in user.
$this->adminUser = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->adminUser);
// Enable import of translations. By default this is disabled for automated
// tests.
$this->config('locale.settings')
->set('translation.import_enabled', TRUE)
->save();
$this->drupalPlaceBlock('local_tasks_block');
}
/**
* Tests the block listing for the translate operation.
*
* There are no blocks placed in the testing profile. Add one, then check
* for Translate operation.
*/
protected function doBlockListTest() {
// Add a test block, any block will do.
// Set the machine name so the translate link can be built later.
$id = Unicode::strtolower($this->randomMachineName(16));
$this->drupalPlaceBlock('system_powered_by_block', ['id' => $id]);
// Get the Block listing.
$this->drupalGet('admin/structure/block');
$translate_link = 'admin/structure/block/manage/' . $id . '/translate';
// Test if the link to translate the block is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the menu listing for the translate operation.
*/
protected function doMenuListTest() {
// Create a test menu to decouple looking for translate operations link so
// this does not test more than necessary.
$this->drupalGet('admin/structure/menu/add');
// Lowercase the machine name.
$menu_name = Unicode::strtolower($this->randomMachineName(16));
$label = $this->randomMachineName(16);
$edit = [
'id' => $menu_name,
'description' => '',
'label' => $label,
];
// Create the menu by posting the form.
$this->drupalPostForm('admin/structure/menu/add', $edit, t('Save'));
// Get the Menu listing.
$this->drupalGet('admin/structure/menu');
$translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate';
// Test if the link to translate the menu is on the page.
$this->assertLinkByHref($translate_link);
// Check if the Link is not added if you are missing 'translate
// configuration' permission.
$permissions = [
'administer menu',
];
$this->drupalLogin($this->drupalCreateUser($permissions));
// Get the Menu listing.
$this->drupalGet('admin/structure/menu');
$translate_link = 'admin/structure/menu/manage/' . $menu_name . '/translate';
// Test if the link to translate the menu is NOT on the page.
$this->assertNoLinkByHref($translate_link);
// Log in as Admin again otherwise the rest will fail.
$this->drupalLogin($this->adminUser);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the vocabulary listing for the translate operation.
*/
protected function doVocabularyListTest() {
// Create a test vocabulary to decouple looking for translate operations
// link so this does not test more than necessary.
$vocabulary = Vocabulary::create([
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'vid' => Unicode::strtolower($this->randomMachineName()),
]);
$vocabulary->save();
// Get the Taxonomy listing.
$this->drupalGet('admin/structure/taxonomy');
$translate_link = 'admin/structure/taxonomy/manage/' . $vocabulary->id() . '/translate';
// Test if the link to translate the vocabulary is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the custom block listing for the translate operation.
*/
public function doCustomContentTypeListTest() {
// Create a test custom block type to decouple looking for translate
// operations link so this does not test more than necessary.
$block_content_type = BlockContentType::create([
'id' => Unicode::strtolower($this->randomMachineName(16)),
'label' => $this->randomMachineName(),
'revision' => FALSE
]);
$block_content_type->save();
// Get the custom block type listing.
$this->drupalGet('admin/structure/block/block-content/types');
$translate_link = 'admin/structure/block/block-content/manage/' . $block_content_type->id() . '/translate';
// Test if the link to translate the custom block type is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the contact forms listing for the translate operation.
*/
public function doContactFormsListTest() {
// Create a test contact form to decouple looking for translate operations
// link so this does not test more than necessary.
$contact_form = ContactForm::create([
'id' => Unicode::strtolower($this->randomMachineName(16)),
'label' => $this->randomMachineName(),
]);
$contact_form->save();
// Get the contact form listing.
$this->drupalGet('admin/structure/contact');
$translate_link = 'admin/structure/contact/manage/' . $contact_form->id() . '/translate';
// Test if the link to translate the contact form is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the content type listing for the translate operation.
*/
public function doContentTypeListTest() {
// Create a test content type to decouple looking for translate operations
// link so this does not test more than necessary.
$content_type = $this->drupalCreateContentType([
'type' => Unicode::strtolower($this->randomMachineName(16)),
'name' => $this->randomMachineName(),
]);
// Get the content type listing.
$this->drupalGet('admin/structure/types');
$translate_link = 'admin/structure/types/manage/' . $content_type->id() . '/translate';
// Test if the link to translate the content type is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the formats listing for the translate operation.
*/
public function doFormatsListTest() {
// Create a test format to decouple looking for translate operations
// link so this does not test more than necessary.
$filter_format = FilterFormat::create([
'format' => Unicode::strtolower($this->randomMachineName(16)),
'name' => $this->randomMachineName(),
]);
$filter_format->save();
// Get the format listing.
$this->drupalGet('admin/config/content/formats');
$translate_link = 'admin/config/content/formats/manage/' . $filter_format->id() . '/translate';
// Test if the link to translate the format is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the shortcut listing for the translate operation.
*/
public function doShortcutListTest() {
// Create a test shortcut to decouple looking for translate operations
// link so this does not test more than necessary.
$shortcut = ShortcutSet::create([
'id' => Unicode::strtolower($this->randomMachineName(16)),
'label' => $this->randomString(),
]);
$shortcut->save();
// Get the shortcut listing.
$this->drupalGet('admin/config/user-interface/shortcut');
$translate_link = 'admin/config/user-interface/shortcut/manage/' . $shortcut->id() . '/translate';
// Test if the link to translate the shortcut is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the role listing for the translate operation.
*/
public function doUserRoleListTest() {
// Create a test role to decouple looking for translate operations
// link so this does not test more than necessary.
$role_id = Unicode::strtolower($this->randomMachineName(16));
$this->drupalCreateRole([], $role_id);
// Get the role listing.
$this->drupalGet('admin/people/roles');
$translate_link = 'admin/people/roles/manage/' . $role_id . '/translate';
// Test if the link to translate the role is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the language listing for the translate operation.
*/
public function doLanguageListTest() {
// Create a test language to decouple looking for translate operations
// link so this does not test more than necessary.
ConfigurableLanguage::createFromLangcode('ga')->save();
// Get the language listing.
$this->drupalGet('admin/config/regional/language');
$translate_link = 'admin/config/regional/language/edit/ga/translate';
// Test if the link to translate the language is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the image style listing for the translate operation.
*/
public function doImageStyleListTest() {
// Get the image style listing.
$this->drupalGet('admin/config/media/image-styles');
$translate_link = 'admin/config/media/image-styles/manage/medium/translate';
// Test if the link to translate the style is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the responsive image mapping listing for the translate operation.
*/
public function doResponsiveImageListTest() {
$edit = [];
$edit['label'] = $this->randomMachineName();
$edit['id'] = strtolower($edit['label']);
$edit['fallback_image_style'] = 'thumbnail';
$this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save'));
$this->assertRaw(t('Responsive image style %label saved.', ['%label' => $edit['label']]));
// Get the responsive image style listing.
$this->drupalGet('admin/config/media/responsive-image-style');
$translate_link = 'admin/config/media/responsive-image-style/' . $edit['id'] . '/translate';
// Test if the link to translate the style is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests the field listing for the translate operation.
*/
public function doFieldListTest() {
// Create a base content type.
$content_type = $this->drupalCreateContentType([
'type' => Unicode::strtolower($this->randomMachineName(16)),
'name' => $this->randomMachineName(),
]);
// Create a block content type.
$block_content_type = BlockContentType::create([
'id' => 'basic',
'label' => 'Basic',
'revision' => FALSE
]);
$block_content_type->save();
$field = FieldConfig::create([
// The field storage is guaranteed to exist because it is supplied by the
// block_content module.
'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'),
'bundle' => $block_content_type->id(),
'label' => 'Body',
'settings' => ['display_summary' => FALSE],
]);
$field->save();
// Look at a few fields on a few entity types.
$pages = [
[
'list' => 'admin/structure/types/manage/' . $content_type->id() . '/fields',
'field' => 'node.' . $content_type->id() . '.body',
],
[
'list' => 'admin/structure/block/block-content/manage/basic/fields',
'field' => 'block_content.basic.body',
],
];
foreach ($pages as $values) {
// Get fields listing.
$this->drupalGet($values['list']);
$translate_link = $values['list'] . '/' . $values['field'] . '/translate';
// Test if the link to translate the field is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
}
/**
* Tests the date format listing for the translate operation.
*/
public function doDateFormatListTest() {
// Get the date format listing.
$this->drupalGet('admin/config/regional/date-time');
$translate_link = 'admin/config/regional/date-time/formats/manage/long/translate';
// Test if the link to translate the format is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests a given settings page for the translate operation.
*
* @param string $link
* URL of the settings page to test.
*/
public function doSettingsPageTest($link) {
// Get the settings page.
$this->drupalGet($link);
$translate_link = $link . '/translate';
// Test if the link to translate the settings page is present.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
}
/**
* Tests if translate link is added to operations in all configuration lists.
*/
public function testTranslateOperationInListUi() {
// All lists based on paths provided by the module.
$this->doBlockListTest();
$this->doMenuListTest();
$this->doVocabularyListTest();
$this->doCustomContentTypeListTest();
$this->doContactFormsListTest();
$this->doContentTypeListTest();
$this->doFormatsListTest();
$this->doShortcutListTest();
$this->doUserRoleListTest();
$this->doLanguageListTest();
$this->doImageStyleListTest();
$this->doResponsiveImageListTest();
$this->doDateFormatListTest();
$this->doFieldListTest();
// Views is tested in Drupal\config_translation\Tests\ConfigTranslationViewListUiTest
// Test the maintenance settings page.
$this->doSettingsPageTest('admin/config/development/maintenance');
// Test the site information settings page.
$this->doSettingsPageTest('admin/config/system/site-information');
// Test the account settings page.
$this->doSettingsPageTest('admin/config/people/accounts');
// Test the RSS settings page.
$this->doSettingsPageTest('admin/config/services/rss-publishing');
}
}

View file

@ -0,0 +1,58 @@
<?php
namespace Drupal\Tests\config_translation\Functional;
use Drupal\views_ui\Tests\UITestBase;
/**
* Visit view list and test if translate is available.
*
* @group config_translation
*/
class ConfigTranslationViewListUiTest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['node', 'test_view'];
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['config_translation', 'views_ui'];
protected function setUp() {
parent::setUp();
$permissions = [
'administer views',
'translate configuration',
];
// Create and log in user.
$this->drupalLogin($this->drupalCreateUser($permissions));
}
/**
* Tests views_ui list to see if translate link is added to operations.
*/
public function testTranslateOperationInViewListUi() {
// Views UI List 'admin/structure/views'.
$this->drupalGet('admin/structure/views');
$translate_link = 'admin/structure/views/view/test_view/translate';
// Test if the link to translate the test_view is on the page.
$this->assertLinkByHref($translate_link);
// Test if the link to translate actually goes to the translate page.
$this->drupalGet($translate_link);
$this->assertRaw('<th>' . t('Language') . '</th>');
// Test that the 'Edit' tab appears.
$this->assertLinkByHref('admin/structure/views/view/test_view');
}
}

View file

@ -2,7 +2,7 @@
namespace Drupal\Tests\config_translation\Kernel\Migrate\d6;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\Tests\SchemaCheckTestTrait;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**

View file

@ -0,0 +1,64 @@
<?php
namespace Drupal\Tests\config_translation\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
/**
* Tests the user profile field instance migration.
*
* @group migrate_drupal_6
*/
class MigrateI18nUserProfileFieldInstanceTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['config_translation', 'locale', 'language', 'field'];
/**
* Tests migration of translated user profile fields.
*/
public function testUserProfileFields() {
$this->executeMigrations([
'user_profile_field',
'user_profile_field_instance',
'd6_i18n_user_profile_field_instance',
]);
$language_manager = $this->container->get('language_manager');
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_love_migrations');
$this->assertSame("J'aime les migrations", $config_translation->get('label'));
$this->assertSame("Si vous cochez cette case, vous aimez les migrations.", $config_translation->get('description'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_color');
$this->assertSame('fr - Favorite color', $config_translation->get('label'));
$this->assertSame('Inscrivez votre couleur préférée', $config_translation->get('description'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_biography');
$this->assertSame('fr - Biography', $config_translation->get('label'));
$this->assertSame('fr - Tell people a little bit about yourself', $config_translation->get('description'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_sell_address');
$this->assertSame('fr - Sell your email address?', $config_translation->get('label'));
$this->assertSame("fr - If you check this box, we'll sell your address to spammers to help line the pockets of our shareholders. Thanks!", $config_translation->get('description'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_sold_to');
$this->assertSame('fr - Sales Category', $config_translation->get('label'));
$this->assertSame("fr - Select the sales categories to which this user's address was sold.", $config_translation->get('description'));
$this->assertSame('fr - Pill spammers Fitness spammers Back\slash Forward/slash Dot.in.the.middle', $config_translation->get('options'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_bands');
$this->assertSame('Mes groupes préférés', $config_translation->get('label'));
$this->assertSame("fr - Enter your favorite bands. When you've saved your profile, you'll be able to find other people with the same favorites.", $config_translation->get('description'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_birthdate');
$this->assertSame('fr - Birthdate', $config_translation->get('label'));
$this->assertSame('fr - Enter your birth date and we\'ll send you a coupon.', $config_translation->get('description'));
$config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.user.user.profile_blog');
$this->assertSame('fr - Blog', $config_translation->get('label'));
$this->assertSame('fr - Paste the full URL, including http://, of your personal blog.', $config_translation->get('description'));
}
}

View file

@ -0,0 +1,79 @@
<?php
namespace Drupal\Tests\config_translation\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests the i18nProfileField source plugin.
*
* @covers \Drupal\config_translation\Plugin\migrate\source\d6\I18nProfileField
* @group migrate_drupal
*/
class I18nProfileFieldTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['config_translation', 'migrate_drupal', 'user'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$test = [];
$test[0]['source_data'] = [
'profile_fields' => [
[
'fid' => 42,
'title' => 'I love migrations',
'name' => 'profile_love_migrations',
],
],
'i18n_strings' => [
[
'lid' => 10,
'objectid' => 'profile_love_migrations',
'type' => 'field',
'property' => 'title',
],
[
'lid' => 11,
'objectid' => 'profile_love_migrations',
'type' => 'field',
'property' => 'explanation'
]
],
'locales_target' => [
[
'lid' => 10,
'translation' => "J'aime les migrations.",
'language' => 'fr',
],
[
'lid' => 11,
'translation' => 'Si vous cochez cette case, vous aimez les migrations.',
'language' => 'fr',
],
],
];
$test[0]['expected_results'] = [
[
'property' => 'title',
'translation' => "J'aime les migrations.",
'language' => 'fr',
'fid' => '42',
'name' => 'profile_love_migrations',
],
[
'property' => 'explanation',
'translation' => 'Si vous cochez cette case, vous aimez les migrations.',
'language' => 'fr',
'fid' => '42',
'name' => 'profile_love_migrations',
],
];
return $test;
}
}

View file

@ -62,14 +62,14 @@ class ConfigEntityMapperTest extends UnitTestCase {
->with('entity.configurable_language.edit_form')
->will($this->returnValue(new Route('/admin/config/regional/language/edit/{configurable_language}')));
$definition = array(
$definition = [
'class' => '\Drupal\config_translation\ConfigEntityMapper',
'base_route_name' => 'entity.configurable_language.edit_form',
'title' => '@label language',
'names' => array(),
'names' => [],
'entity_type' => 'configurable_language',
'route_name' => 'config_translation.item.overview.entity.configurable_language.edit_form',
);
];
$typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
@ -152,7 +152,7 @@ class ConfigEntityMapperTest extends UnitTestCase {
$result = $this->configEntityMapper->getOverviewRouteParameters();
$this->assertSame(array('configurable_language' => 'entity_id'), $result);
$this->assertSame(['configurable_language' => 'entity_id'], $result);
}
/**
@ -205,12 +205,12 @@ class ConfigEntityMapperTest extends UnitTestCase {
public function testGetOperations() {
$result = $this->configEntityMapper->getOperations();
$expected = array(
'list' => array(
$expected = [
'list' => [
'title' => 'List',
'url' => Url::fromRoute('config_translation.entity_list', ['mapper_id' => 'configurable_language']),
),
);
],
];
$this->assertEquals($expected, $result);
}

View file

@ -42,13 +42,13 @@ class ConfigFieldMapperTest extends UnitTestCase {
$this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$this->entity = $this->getMock('Drupal\field\FieldConfigInterface');
$definition = array(
$definition = [
'class' => '\Drupal\config_translation\ConfigFieldMapper',
'base_route_name' => 'entity.field_config.node_field_edit_form',
'title' => '@label field',
'names' => array(),
'names' => [],
'entity_type' => 'field_config',
);
];
$locale_config_manager = $this->getMockBuilder('Drupal\locale\LocaleConfigManager')
->disableOriginalConstructor()

View file

@ -31,7 +31,7 @@ class ConfigMapperManagerTest extends UnitTestCase {
protected $typedConfigManager;
protected function setUp() {
$language = new Language(array('id' => 'en'));
$language = new Language(['id' => 'en']);
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$language_manager->expects($this->once())
->method('getCurrentLanguage')
@ -83,50 +83,50 @@ class ConfigMapperManagerTest extends UnitTestCase {
* ConfigMapperManager::hasTranslatable() as the second key.
*/
public function providerTestHasTranslatable() {
return array(
array($this->getElement(array()), FALSE),
array($this->getElement(array('aaa' => 'bbb')), FALSE),
array($this->getElement(array('translatable' => FALSE)), FALSE),
array($this->getElement(array('translatable' => TRUE)), TRUE),
array($this->getNestedElement(array(
$this->getElement(array()),
)), FALSE),
array($this->getNestedElement(array(
$this->getElement(array('translatable' => TRUE)),
)), TRUE),
array($this->getNestedElement(array(
$this->getElement(array('aaa' => 'bbb')),
$this->getElement(array('ccc' => 'ddd')),
$this->getElement(array('eee' => 'fff')),
)), FALSE),
array($this->getNestedElement(array(
$this->getElement(array('aaa' => 'bbb')),
$this->getElement(array('ccc' => 'ddd')),
$this->getElement(array('translatable' => TRUE)),
)), TRUE),
array($this->getNestedElement(array(
$this->getElement(array('aaa' => 'bbb')),
$this->getNestedElement(array(
$this->getElement(array('ccc' => 'ddd')),
$this->getElement(array('eee' => 'fff')),
)),
$this->getNestedElement(array(
$this->getElement(array('ggg' => 'hhh')),
$this->getElement(array('iii' => 'jjj')),
)),
)), FALSE),
array($this->getNestedElement(array(
$this->getElement(array('aaa' => 'bbb')),
$this->getNestedElement(array(
$this->getElement(array('ccc' => 'ddd')),
$this->getElement(array('eee' => 'fff')),
)),
$this->getNestedElement(array(
$this->getElement(array('ggg' => 'hhh')),
$this->getElement(array('translatable' => TRUE)),
)),
)), TRUE),
);
return [
[$this->getElement([]), FALSE],
[$this->getElement(['aaa' => 'bbb']), FALSE],
[$this->getElement(['translatable' => FALSE]), FALSE],
[$this->getElement(['translatable' => TRUE]), TRUE],
[$this->getNestedElement([
$this->getElement([]),
]), FALSE],
[$this->getNestedElement([
$this->getElement(['translatable' => TRUE]),
]), TRUE],
[$this->getNestedElement([
$this->getElement(['aaa' => 'bbb']),
$this->getElement(['ccc' => 'ddd']),
$this->getElement(['eee' => 'fff']),
]), FALSE],
[$this->getNestedElement([
$this->getElement(['aaa' => 'bbb']),
$this->getElement(['ccc' => 'ddd']),
$this->getElement(['translatable' => TRUE]),
]), TRUE],
[$this->getNestedElement([
$this->getElement(['aaa' => 'bbb']),
$this->getNestedElement([
$this->getElement(['ccc' => 'ddd']),
$this->getElement(['eee' => 'fff']),
]),
$this->getNestedElement([
$this->getElement(['ggg' => 'hhh']),
$this->getElement(['iii' => 'jjj']),
]),
]), FALSE],
[$this->getNestedElement([
$this->getElement(['aaa' => 'bbb']),
$this->getNestedElement([
$this->getElement(['ccc' => 'ddd']),
$this->getElement(['eee' => 'fff']),
]),
$this->getNestedElement([
$this->getElement(['ggg' => 'hhh']),
$this->getElement(['translatable' => TRUE]),
]),
]), TRUE],
];
}
/**

View file

@ -91,13 +91,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
protected function setUp() {
$this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
$this->pluginDefinition = array(
$this->pluginDefinition = [
'class' => '\Drupal\config_translation\ConfigNamesMapper',
'base_route_name' => 'system.site_information_settings',
'title' => 'System information',
'names' => array('system.site'),
'names' => ['system.site'],
'weight' => 42,
);
];
$this->typedConfigManager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface');
@ -156,7 +156,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetBaseRouteParameters() {
$result = $this->configNamesMapper->getBaseRouteParameters();
$this->assertSame(array(), $result);
$this->assertSame([], $result);
}
/**
@ -193,7 +193,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetOverviewRouteParameters() {
$result = $this->configNamesMapper->getOverviewRouteParameters();
$this->assertSame(array(), $result);
$this->assertSame([], $result);
}
/**
@ -201,13 +201,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetOverviewRoute() {
$expected = new Route('/admin/config/system/site-information/translate',
array(
[
'_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage',
'plugin_id' => 'system.site_information_settings',
),
array(
],
[
'_config_translation_overview_access' => 'TRUE',
)
]
);
$result = $this->configNamesMapper->getOverviewRoute();
$this->assertSame(serialize($expected), serialize($result));
@ -242,7 +242,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
$route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']);
$this->configNamesMapper->populateFromRouteMatch($route_match);
$expected = array('langcode' => 'xx');
$expected = ['langcode' => 'xx'];
$result = $this->configNamesMapper->getAddRouteParameters();
$this->assertSame($expected, $result);
}
@ -252,13 +252,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetAddRoute() {
$expected = new Route('/admin/config/system/site-information/translate/{langcode}/add',
array(
[
'_form' => '\Drupal\config_translation\Form\ConfigTranslationAddForm',
'plugin_id' => 'system.site_information_settings',
),
array(
],
[
'_config_translation_form_access' => 'TRUE',
)
]
);
$result = $this->configNamesMapper->getAddRoute();
$this->assertSame(serialize($expected), serialize($result));
@ -280,7 +280,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
$route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']);
$this->configNamesMapper->populateFromRouteMatch($route_match);
$expected = array('langcode' => 'xx');
$expected = ['langcode' => 'xx'];
$result = $this->configNamesMapper->getEditRouteParameters();
$this->assertSame($expected, $result);
}
@ -290,13 +290,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetEditRoute() {
$expected = new Route('/admin/config/system/site-information/translate/{langcode}/edit',
array(
[
'_form' => '\Drupal\config_translation\Form\ConfigTranslationEditForm',
'plugin_id' => 'system.site_information_settings',
),
array(
],
[
'_config_translation_form_access' => 'TRUE',
)
]
);
$result = $this->configNamesMapper->getEditRoute();
$this->assertSame(serialize($expected), serialize($result));
@ -318,7 +318,7 @@ class ConfigNamesMapperTest extends UnitTestCase {
$route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']);
$this->configNamesMapper->populateFromRouteMatch($route_match);
$expected = array('langcode' => 'xx'); $result = $this->configNamesMapper->getDeleteRouteParameters();
$expected = ['langcode' => 'xx']; $result = $this->configNamesMapper->getDeleteRouteParameters();
$this->assertSame($expected, $result);
}
@ -327,13 +327,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
*/
public function testGetDeleteRoute() {
$expected = new Route('/admin/config/system/site-information/translate/{langcode}/delete',
array(
[
'_form' => '\Drupal\config_translation\Form\ConfigTranslationDeleteForm',
'plugin_id' => 'system.site_information_settings',
),
array(
],
[
'_config_translation_form_access' => 'TRUE',
)
]
);
$result = $this->configNamesMapper->getDeleteRoute();
$this->assertSame(serialize($expected), serialize($result));
@ -403,38 +403,38 @@ class ConfigNamesMapperTest extends UnitTestCase {
public function testGetLangcode() {
// Test that the getLangcode() falls back to 'en', if no explicit language
// code is provided.
$config_factory = $this->getConfigFactoryStub(array(
'system.site' => array('key' => 'value'),
));
$config_factory = $this->getConfigFactoryStub([
'system.site' => ['key' => 'value'],
]);
$this->configNamesMapper->setConfigFactory($config_factory);
$result = $this->configNamesMapper->getLangcode();
$this->assertSame('en', $result);
// Test that getLangcode picks up the language code provided by the
// configuration.
$config_factory = $this->getConfigFactoryStub(array(
'system.site' => array('langcode' => 'xx'),
));
$config_factory = $this->getConfigFactoryStub([
'system.site' => ['langcode' => 'xx'],
]);
$this->configNamesMapper->setConfigFactory($config_factory);
$result = $this->configNamesMapper->getLangcode();
$this->assertSame('xx', $result);
// Test that getLangcode() works for multiple configuration names.
$this->configNamesMapper->addConfigName('system.maintenance');
$config_factory = $this->getConfigFactoryStub(array(
'system.site' => array('langcode' => 'xx'),
'system.maintenance' => array('langcode' => 'xx'),
));
$config_factory = $this->getConfigFactoryStub([
'system.site' => ['langcode' => 'xx'],
'system.maintenance' => ['langcode' => 'xx'],
]);
$this->configNamesMapper->setConfigFactory($config_factory);
$result = $this->configNamesMapper->getLangcode();
$this->assertSame('xx', $result);
// Test that getLangcode() throws an exception when different language codes
// are given.
$config_factory = $this->getConfigFactoryStub(array(
'system.site' => array('langcode' => 'xx'),
'system.maintenance' => array('langcode' => 'yy'),
));
$config_factory = $this->getConfigFactoryStub([
'system.site' => ['langcode' => 'xx'],
'system.maintenance' => ['langcode' => 'yy'],
]);
$this->configNamesMapper->setConfigFactory($config_factory);
try {
$this->configNamesMapper->getLangcode();
@ -448,22 +448,22 @@ class ConfigNamesMapperTest extends UnitTestCase {
* Tests ConfigNamesMapper::getConfigData().
*/
public function testGetConfigData() {
$configs = array(
'system.site' => array(
$configs = [
'system.site' => [
'name' => 'Drupal',
'slogan' => 'Come for the software, stay for the community!',
),
'system.maintenance' => array(
],
'system.maintenance' => [
'enabled' => FALSE,
'message' => '@site is currently under maintenance.',
),
'system.rss' => array(
'items' => array(
],
'system.rss' => [
'items' => [
'limit' => 10,
'view_mode' => 'rss',
),
),
);
],
],
];
$this->configNamesMapper->setConfigNames(array_keys($configs));
$config_factory = $this->getConfigFactoryStub($configs);
@ -489,9 +489,9 @@ class ConfigNamesMapperTest extends UnitTestCase {
$config_names = range(1, count($mock_return_values));
$this->configNamesMapper->setConfigNames($config_names);
$map = array();
$map = [];
foreach ($config_names as $i => $config_name) {
$map[] = array($config_name, $mock_return_values[$i]);
$map[] = [$config_name, $mock_return_values[$i]];
}
$this->typedConfigManager
->expects($this->any())
@ -512,12 +512,12 @@ class ConfigNamesMapperTest extends UnitTestCase {
* ConfigNamesMapper::hasSchema() as the second value.
*/
public function providerTestHasSchema() {
return array(
array(array(TRUE), TRUE),
array(array(FALSE), FALSE),
array(array(TRUE, TRUE, TRUE), TRUE),
array(array(TRUE, FALSE, TRUE), FALSE),
);
return [
[[TRUE], TRUE],
[[FALSE], FALSE],
[[TRUE, TRUE, TRUE], TRUE],
[[TRUE, FALSE, TRUE], FALSE],
];
}
/**
@ -536,9 +536,9 @@ class ConfigNamesMapperTest extends UnitTestCase {
$config_names = range(1, count($mock_return_values));
$this->configNamesMapper->setConfigNames($config_names);
$map = array();
$map = [];
foreach ($config_names as $i => $config_name) {
$map[] = isset($mock_return_values[$i]) ? array($config_name, $mock_return_values[$i]) : array();
$map[] = isset($mock_return_values[$i]) ? [$config_name, $mock_return_values[$i]] : [];
}
$this->configMapperManager
->expects($this->any())
@ -559,14 +559,14 @@ class ConfigNamesMapperTest extends UnitTestCase {
* ConfigNamesMapper::hasTranslatable() as the second value.
*/
public function providerTestHasTranslatable() {
return array(
array(array(), FALSE),
array(array(TRUE), TRUE),
array(array(FALSE), FALSE),
array(array(TRUE, TRUE, TRUE), TRUE),
array(array(FALSE, FALSE, FALSE), FALSE),
array(array(TRUE, FALSE, TRUE), TRUE),
);
return [
[[], FALSE],
[[TRUE], TRUE],
[[FALSE], FALSE],
[[TRUE, TRUE, TRUE], TRUE],
[[FALSE, FALSE, FALSE], FALSE],
[[TRUE, FALSE, TRUE], TRUE],
];
}
/**
@ -587,9 +587,9 @@ class ConfigNamesMapperTest extends UnitTestCase {
$config_names = range(1, count($mock_return_values));
$this->configNamesMapper->setConfigNames($config_names);
$map = array();
$map = [];
foreach ($config_names as $i => $config_name) {
$map[] = array($config_name, $language->getId(), $mock_return_values[$i]);
$map[] = [$config_name, $language->getId(), $mock_return_values[$i]];
}
$this->localeConfigManager
->expects($this->any())
@ -610,13 +610,13 @@ class ConfigNamesMapperTest extends UnitTestCase {
* ConfigNamesMapper::hasTranslation() as the second value.
*/
public function providerTestHasTranslation() {
return array(
array(array(TRUE), TRUE),
array(array(FALSE), FALSE),
array(array(TRUE, TRUE, TRUE), TRUE),
array(array(FALSE, FALSE, TRUE), TRUE),
array(array(FALSE, FALSE, FALSE), FALSE),
);
return [
[[TRUE], TRUE],
[[FALSE], FALSE],
[[TRUE, TRUE, TRUE], TRUE],
[[FALSE, FALSE, TRUE], TRUE],
[[FALSE, FALSE, FALSE], FALSE],
];
}
/**
@ -631,12 +631,12 @@ class ConfigNamesMapperTest extends UnitTestCase {
* Tests ConfigNamesMapper::hasTranslation().
*/
public function testGetOperations() {
$expected = array(
'translate' => array(
$expected = [
'translate' => [
'title' => 'Translate',
'url' => Url::fromRoute('config_translation.item.overview.system.site_information_settings'),
),
);
],
];
$result = $this->configNamesMapper->getOperations();
$this->assertEquals($expected, $result);
}