|
|
|
@ -77,7 +77,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
$this->drupalLogin($this->editor);
|
|
|
|
|
$this->entityId = $this->createEntity($values[$default_langcode], $default_langcode);
|
|
|
|
|
$this->drupalLogin($this->translator);
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->assertTrue($entity, 'Entity found in the database.');
|
|
|
|
|
$this->drupalGet($entity->urlInfo());
|
|
|
|
|
$this->assertResponse(200, 'Entity URL is valid.');
|
|
|
|
@ -119,7 +122,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
|
|
|
|
|
// Ensure that the content language cache context is not yet added to the
|
|
|
|
|
// page.
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->drupalGet($entity->urlInfo());
|
|
|
|
|
$this->assertCacheContexts(Cache::mergeContexts(['languages:language_content'], $this->defaultCacheContexts));
|
|
|
|
|
|
|
|
|
@ -154,7 +160,8 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
if ($this->testLanguageSelector) {
|
|
|
|
|
$this->assertNoFieldByXPath('//select[@id="edit-langcode-0-value"]', NULL, 'Language selector correctly disabled on translations.');
|
|
|
|
|
}
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->drupalGet($entity->urlInfo('drupal:content-translation-overview'));
|
|
|
|
|
$this->assertNoText('Source language', 'Source language column correctly hidden.');
|
|
|
|
|
|
|
|
|
@ -184,7 +191,8 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
'target' => $langcode
|
|
|
|
|
], array('language' => $language));
|
|
|
|
|
$this->drupalPostForm($add_url, $edit, $this->getFormSubmitActionForNewTranslation($entity, $langcode));
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->drupalGet($entity->urlInfo('drupal:content-translation-overview'));
|
|
|
|
|
$this->assertText('Source language', 'Source language column correctly shown.');
|
|
|
|
|
|
|
|
|
@ -204,7 +212,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
* Tests that the translation overview shows the correct values.
|
|
|
|
|
*/
|
|
|
|
|
protected function doTestTranslationOverview() {
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$translate_url = $entity->urlInfo('drupal:content-translation-overview');
|
|
|
|
|
$this->drupalGet($translate_url);
|
|
|
|
|
$translate_url->setAbsolute(FALSE);
|
|
|
|
@ -226,7 +237,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
* Tests up-to-date status tracking.
|
|
|
|
|
*/
|
|
|
|
|
protected function doTestOutdatedStatus() {
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$langcode = 'fr';
|
|
|
|
|
$languages = \Drupal::languageManager()->getLanguages();
|
|
|
|
|
|
|
|
|
@ -234,7 +248,8 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
$edit = array('content_translation[retranslate]' => TRUE);
|
|
|
|
|
$edit_path = $entity->urlInfo('edit-form', array('language' => $languages[$langcode]));
|
|
|
|
|
$this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode));
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
|
|
|
|
|
// Check that every translation has the correct "outdated" status, and that
|
|
|
|
|
// the Translation fieldset is open if the translation is "outdated".
|
|
|
|
@ -252,7 +267,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $added_langcode));
|
|
|
|
|
$this->drupalGet($url);
|
|
|
|
|
$this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is now shown.');
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->assertFalse($this->manager->getTranslationMetadata($entity->getTranslation($added_langcode))->isOutdated(), 'The "outdated" status has been correctly stored.');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -262,7 +280,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
* Tests the translation publishing status.
|
|
|
|
|
*/
|
|
|
|
|
protected function doTestPublishedStatus() {
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
|
|
|
|
|
// Unpublish translations.
|
|
|
|
|
foreach ($this->langcodes as $index => $langcode) {
|
|
|
|
@ -270,7 +291,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
$url = $entity->urlInfo('edit-form', array('language' => ConfigurableLanguage::load($langcode)));
|
|
|
|
|
$edit = array('content_translation[status]' => FALSE);
|
|
|
|
|
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->assertFalse($this->manager->getTranslationMetadata($entity->getTranslation($langcode))->isPublished(), 'The translation has been correctly unpublished.');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -284,7 +308,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
* Tests the translation authoring information.
|
|
|
|
|
*/
|
|
|
|
|
protected function doTestAuthoringInfo() {
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$values = array();
|
|
|
|
|
|
|
|
|
|
// Post different authoring information for each translation.
|
|
|
|
@ -302,7 +329,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
$this->drupalPostForm($url, $edit, $this->getFormSubmitAction($entity, $langcode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
foreach ($this->langcodes as $langcode) {
|
|
|
|
|
$metadata = $this->manager->getTranslationMetadata($entity->getTranslation($langcode));
|
|
|
|
|
$this->assertEqual($metadata->getAuthor()->id(), $values[$langcode]['uid'], 'Translation author correctly stored.');
|
|
|
|
@ -330,12 +360,16 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
// Confirm and delete a translation.
|
|
|
|
|
$this->drupalLogin($this->translator);
|
|
|
|
|
$langcode = 'fr';
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$language = ConfigurableLanguage::load($langcode);
|
|
|
|
|
$url = $entity->urlInfo('edit-form', array('language' => $language));
|
|
|
|
|
$this->drupalPostForm($url, array(), t('Delete translation'));
|
|
|
|
|
$this->drupalPostForm(NULL, array(), t('Delete @language translation', array('@language' => $language->getName())));
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId, TRUE);
|
|
|
|
|
if ($this->assertTrue(is_object($entity), 'Entity found')) {
|
|
|
|
|
$translations = $entity->getTranslationLanguages();
|
|
|
|
|
$this->assertTrue(count($translations) == 2 && empty($translations[$langcode]), 'Translation successfully deleted.');
|
|
|
|
@ -465,7 +499,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
* Tests edit content translation.
|
|
|
|
|
*/
|
|
|
|
|
protected function doTestTranslationEdit() {
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$languages = $this->container->get('language_manager')->getLanguages();
|
|
|
|
|
|
|
|
|
|
foreach ($this->langcodes as $langcode) {
|
|
|
|
@ -484,7 +521,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
* Tests the basic translation workflow.
|
|
|
|
|
*/
|
|
|
|
|
protected function doTestTranslationChanged() {
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$changed_field_name = $this->getChangedFieldName($entity);
|
|
|
|
|
$definition = $entity->getFieldDefinition($changed_field_name);
|
|
|
|
|
$config = $definition->getConfig($entity->bundle());
|
|
|
|
@ -517,7 +557,10 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
$edit_path = $entity->urlInfo('edit-form', array('language' => $language));
|
|
|
|
|
$this->drupalPostForm($edit_path, $edit, $this->getFormSubmitAction($entity, $langcode));
|
|
|
|
|
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->assertEqual(
|
|
|
|
|
$entity->getChangedTimeAcrossTranslations(), $entity->getTranslation($langcode)->getChangedTime(),
|
|
|
|
|
format_string('Changed time for language %language is the latest change over all languages.', array('%language' => $language->getName()))
|
|
|
|
@ -551,13 +594,19 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
* Test the changed time after API and FORM save without changes.
|
|
|
|
|
*/
|
|
|
|
|
public function doTestChangedTimeAfterSaveWithoutChanges() {
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
// Test only entities, which implement the EntityChangedInterface.
|
|
|
|
|
if ($entity->getEntityType()->isSubclassOf('Drupal\Core\Entity\EntityChangedInterface')) {
|
|
|
|
|
$changed_timestamp = $entity->getChangedTime();
|
|
|
|
|
|
|
|
|
|
$entity->save();
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage = $this->container->get('entity_type.manager')
|
|
|
|
|
->getStorage($this->entityTypeId);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->assertEqual($changed_timestamp, $entity->getChangedTime(), 'The entity\'s changed time wasn\'t updated after API save without changes.');
|
|
|
|
|
|
|
|
|
|
// Ensure different save timestamps.
|
|
|
|
@ -568,7 +617,8 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
|
|
|
|
|
$edit_path = $entity->urlInfo('edit-form', array('language' => $language));
|
|
|
|
|
$this->drupalPostForm($edit_path, [], $this->getFormSubmitAction($entity, $language->getId()));
|
|
|
|
|
|
|
|
|
|
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
|
|
|
|
|
$storage->resetCache([$this->entityId]);
|
|
|
|
|
$entity = $storage->load($this->entityId);
|
|
|
|
|
$this->assertNotEqual($changed_timestamp, $entity->getChangedTime(), 'The entity\'s changed time was updated after form save without changes.');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|