Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -290,8 +290,8 @@ class ContentTranslationHandler implements ContentTranslationHandlerInterface, E
$title = $this->entityFormTitle($entity);
// When editing the original values display just the entity label.
if ($form_langcode != $entity_langcode) {
$t_args = array('%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label(), '!title' => $title);
$title = empty($source_langcode) ? t('!title [%language translation]', $t_args) : t('Create %language translation of %title', $t_args);
$t_args = array('%language' => $languages[$form_langcode]->getName(), '%title' => $entity->label(), '@title' => $title);
$title = empty($source_langcode) ? t('@title [%language translation]', $t_args) : t('Create %language translation of %title', $t_args);
}
$form['#title'] = $title;
}

View file

@ -62,7 +62,7 @@ class ContentTranslationUpdatesManager implements EventSubscriberInterface {
foreach (array_diff_key($storage_definitions, $installed_storage_definitions) as $storage_definition) {
/** @var $storage_definition \Drupal\Core\Field\FieldStorageDefinitionInterface */
if ($storage_definition->getProvider() == 'content_translation') {
$this->entityManager->onFieldStorageDefinitionCreate($storage_definition);
$this->updateManager->installFieldStorageDefinition($storage_definition->getName(), $entity_type_id, 'content_translation', $storage_definition);
}
}
}

View file

@ -69,6 +69,7 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
'entity_type_id' => $entity_type_id,
),
array(
'_entity_access' => $entity_type_id . '.view',
'_access_content_translation_overview' => $entity_type_id,
),
array(
@ -94,6 +95,7 @@ class ContentTranslationRouteSubscriber extends RouteSubscriberBase {
),
array(
'_entity_access' => $entity_type_id . '.view',
'_access_content_translation_manage' => 'create',
),
array(

View file

@ -14,6 +14,11 @@ namespace Drupal\content_translation\Tests;
*/
class ContentTestTranslationUITest extends ContentTranslationUITestBase {
/**
* {@inheritdoc}
*/
protected $testHTMLEscapeForAllLanguages = TRUE;
/**
* Modules to enable.
*
@ -21,6 +26,18 @@ class ContentTestTranslationUITest extends ContentTranslationUITestBase {
*/
public static $modules = array('language', 'content_translation', 'entity_test');
/**
* {@inheritdoc}
*/
protected $defaultCacheContexts = [
'languages:language_interface',
'theme',
'url.path',
'url.query_args',
'user.permissions',
'user.roles:authenticated',
];
/**
* Overrides \Drupal\simpletest\WebTestBase::setUp().
*/
@ -34,7 +51,7 @@ class ContentTestTranslationUITest extends ContentTranslationUITestBase {
* Overrides \Drupal\content_translation\Tests\ContentTranslationUITestBase::getTranslatorPermission().
*/
protected function getTranslatorPermissions() {
return array_merge(parent::getTranslatorPermissions(), array('administer entity_test content'));
return array_merge(parent::getTranslatorPermissions(), array('administer entity_test content', 'view test entity'));
}
}

View file

@ -61,7 +61,7 @@ class ContentTranslationMetadataFieldsTest extends ContentTranslationTestBase {
// Create a new test entity with original values in the default language.
$default_langcode = $this->langcodes[0];
$entity_id = $this->createEntity([], $default_langcode);
$entity_id = $this->createEntity(['title' => $this->randomString()], $default_langcode);
$storage = $entity_manager->getStorage($this->entityTypeId);
$storage->resetCache();
$entity = $storage->load($entity_id);
@ -118,7 +118,7 @@ class ContentTranslationMetadataFieldsTest extends ContentTranslationTestBase {
// Create a new test entity with original values in the default language.
$default_langcode = $this->langcodes[0];
$entity_id = $this->createEntity(['status' => FALSE], $default_langcode);
$entity_id = $this->createEntity(['title' => $this->randomString(), 'status' => FALSE], $default_langcode);
$storage = $entity_manager->getStorage($this->entityTypeId);
$storage->resetCache();
$entity = $storage->load($entity_id);

View file

@ -9,6 +9,7 @@ namespace Drupal\content_translation\Tests;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Tests\NodeTestBase;
use Drupal\user\Entity\Role;
/**
* Tests the content translation operations available in the content listing.
@ -75,6 +76,63 @@ class ContentTranslationOperationsTest extends NodeTestBase {
$this->drupalLogin($this->baseUser2);
$this->drupalGet('admin/content');
$this->assertLinkByHref('node/' . $node->id() . '/translations');
// Ensure that an unintended misconfiguration of permissions does not open
// access to the translation form, see https://www.drupal.org/node/2558905.
$this->drupalLogout();
user_role_change_permissions(
Role::AUTHENTICATED_ID,
[
'create content translations' => TRUE,
'access content' => FALSE,
]
);
$this->drupalLogin($this->baseUser1);
$this->drupalGet($node->urlInfo('drupal:content-translation-overview'));
$this->assertResponse(403);
// Ensure that the translation overview is also not accessible when the user
// has 'access content', but the node is not published.
user_role_change_permissions(
Role::AUTHENTICATED_ID,
[
'create content translations' => TRUE,
'access content' => TRUE,
]
);
$node->setPublished(FALSE)->save();
$this->drupalGet($node->urlInfo('drupal:content-translation-overview'));
$this->assertResponse(403);
}
/**
* @see content_translation_translate_access()
*/
public function testContentTranslationOverviewAccess() {
$access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node');
$user = $this->createUser(['create content translations', 'access content']);
$this->drupalLogin($user);
$node = $this->drupalCreateNode(['status' => FALSE, 'type' => 'article']);
$this->assertFalse(content_translation_translate_access($node)->isAllowed());
$access_control_handler->resetCache();
$node->setPublished(TRUE);
$node->save();
$this->assertTrue(content_translation_translate_access($node)->isAllowed());
$access_control_handler->resetCache();
user_role_change_permissions(
Role::AUTHENTICATED_ID,
[
'access content' => FALSE,
]
);
$user = $this->createUser(['create content translations']);
$this->drupalLogin($user);
$this->assertFalse(content_translation_translate_access($node)->isAllowed());
$access_control_handler->resetCache();
}
}

View file

@ -37,6 +37,14 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
*/
protected $testLanguageSelector = TRUE;
/**
* Flag that tells whether the HTML escaping of all languages works or not
* after SafeMarkup change.
*
* @var bool
*/
protected $testHTMLEscapeForAllLanguages = FALSE;
/**
* Default cache contexts expected on a non-translated entity.
*
@ -44,7 +52,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
*
* @var string[]
*/
protected $defaultCacheContexts = ['languages:language_interface', 'theme', 'user.permissions'];
protected $defaultCacheContexts = ['languages:language_interface', 'theme', 'url.query_args:_wrapper_format', 'user.permissions'];
/**
* Tests the basic translation UI.
@ -105,6 +113,13 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
], array('language' => $language));
$this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), $this->getFormSubmitActionForNewTranslation($entity, $langcode));
// Assert that HTML is escaped in "all languages" in UI after SafeMarkup
// change.
if ($this->testHTMLEscapeForAllLanguages) {
$this->assertNoRaw('<span class="translation-entity-all-languages">(all languages)</span>');
$this->assertRaw('<span class="translation-entity-all-languages">(all languages)</span>');
}
// Ensure that the content language cache context is not yet added to the
// page.
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);

View file

@ -38,6 +38,16 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
$this->setupEntity();
}
/**
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
$permissions = parent::getTranslatorPermissions();
$permissions[] = 'view test entity';
return $permissions;
}
/**
* Overrides \Drupal\content_translation\Tests\ContentTranslationTestBase::getEditorPermissions().
*/
@ -109,7 +119,7 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
$ops = array('create' => t('Add'), 'update' => t('Edit'), 'delete' => t('Delete'));
$translations_url = $this->entity->urlInfo('drupal:content-translation-overview');
foreach ($ops as $current_op => $item) {
$user = $this->drupalCreateUser(array($this->getTranslatePermission(), "$current_op content translations"));
$user = $this->drupalCreateUser(array($this->getTranslatePermission(), "$current_op content translations", 'view test entity'));
$this->drupalLogin($user);
$this->drupalGet($translations_url);

View file

@ -54,6 +54,15 @@ class TranslationLinkTest extends ContentTranslationTestBase {
ViewTestData::createTestViews(get_class($this), array('content_translation_test_views'));
}
/**
* {@inheritdoc}
*/
protected function getTranslatorPermissions() {
$permissions = parent::getTranslatorPermissions();
$permissions[] = 'access user profiles';
return $permissions;
}
/**
* Tests the content translation overview link field handler.
*/