Test for translatable entity types with no canonical link template.
@group tmgmt
Expanded class hierarchy of ContentTmgmtEntitySourceNoCanonicalLinkTest
class ContentTmgmtEntitySourceNoCanonicalLinkTest extends TMGMTTestBase {
use TmgmtEntityTestTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = array(
'content_translation_test',
'language',
'entity_test',
'tmgmt_content',
);
/**
* {@inheritdoc}
*/
function setUp() : void {
parent::setUp();
$this
->loginAsAdmin(array(
'create translation jobs',
'submit translation jobs',
'accept translation jobs',
'administer content translation',
'access content overview',
'update content translations',
'translate any entity',
));
// Enable entity translations for entity_test_translatable_UI_skip.
$content_translation_manager = \Drupal::service('content_translation.manager');
$content_translation_manager
->setEnabled('entity_test_translatable_UI_skip', 'entity_test_translatable_UI_skip', TRUE);
$this
->addLanguage('de');
}
/**
* Tests for no canonical link templates.
*/
public function testNoCanonicalLinkTemplate() {
// Create an entity that has no canonical link but is translatable.
$entity = EntityTestTranslatableUISkip::create([
'name' => 'name english',
'langcode' => 'en',
]);
$entity
->save();
// Go to the overview page and assert that the entity label appears.
$this
->drupalGet('admin/tmgmt/sources/content/entity_test_translatable_UI_skip');
$this
->assertSession()
->pageTextContains($entity
->label());
// Add a translation to the entity and submit it to the provider.
$edit = [
'items[' . $entity
->id() . ']' => TRUE,
];
$this
->submitForm($edit, 'Request translation');
$this
->submitForm([], 'Submit to provider');
$this
->assertSession()
->pageTextContains('The translation of ' . $entity
->label() . ' to German is finished and can now be reviewed.');
// Review and save the entity translation.
$this
->clickLink('reviewed');
// Non-publishable and non-moderated entities do not have publish status
// form element.
$this
->assertSession()
->pageTextNotContains('Translation publish status');
$this
->assertSession()
->fieldNotExists('edit-moderation-state-new-state');
$this
->submitForm([], 'Save as completed');
$this
->assertSession()
->titleEquals($entity
->label() . ' (English to German, Finished) | Drupal');
$this
->assertSession()
->pageTextContains('The translation for name english has been accepted as de(de-ch): name english.');
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContentTmgmtEntitySourceNoCanonicalLinkTest:: |
protected static | property |
Modules to enable. Overrides TMGMTTestBase:: |
|
ContentTmgmtEntitySourceNoCanonicalLinkTest:: |
function |
Overrides DrupalWebTestCase::setUp() Overrides TMGMTTestBase:: |
||
ContentTmgmtEntitySourceNoCanonicalLinkTest:: |
public | function | Tests for no canonical link templates. | |
TmgmtEntityTestTrait:: |
public | property | ||
TmgmtEntityTestTrait:: |
function | Creates fields of type text and text_with_summary of different cardinality. | ||
TmgmtEntityTestTrait:: |
function | Creates node type with several text fields with different cardinality. | ||
TmgmtEntityTestTrait:: |
function | Creates a taxonomy term of a given vocabulary. | ||
TmgmtEntityTestTrait:: |
function | Creates taxonomy vocabulary with custom fields. | ||
TmgmtEntityTestTrait:: |
protected | function | Creates a node of a given bundle. | |
TMGMTTestBase:: |
protected | property | ||
TMGMTTestBase:: |
protected | property | A default translator using the test translator. | |
TmgmtTestTrait:: |
protected | property | List of permissions used by loginAsAdmin(). | |
TmgmtTestTrait:: |
protected | property | Drupal user object created by loginAsAdmin(). | |
TmgmtTestTrait:: |
protected | property | The language weight for new languages. | |
TmgmtTestTrait:: |
protected | property | List of permissions used by loginAsTranslator(). | |
TmgmtTestTrait:: |
protected | property | Drupal user object created by loginAsTranslator(). | |
TmgmtTestTrait:: |
function | Sets the proper environment. | ||
TmgmtTestTrait:: |
function | Asserts job item language codes. | ||
TmgmtTestTrait:: |
protected | function | Asserts text in the page with an xpath expression. | |
TmgmtTestTrait:: |
function | Clicks on an image link with the provided title attribute. | ||
TmgmtTestTrait:: |
function | Creates, saves and returns a translation job. | ||
TmgmtTestTrait:: |
function | Creates, saves and returns a translator. | ||
TmgmtTestTrait:: |
function | Will create a user with admin permissions and log it in. | ||
TmgmtTestTrait:: |
function | Will create a user with translator permissions and log it in. |