Error message

  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).
  • Warning: count(): Parameter must be an array or an object that implements Countable in _api_make_match_member_link() (line 1230 of /home/projects/api/www/sites/all/modules/api/api.formatting.inc).

class ContentTmgmtEntitySourceNoCanonicalLinkTest

Test for translatable entity types with no canonical link template.

@group tmgmt

Hierarchy

Expanded class hierarchy of ContentTmgmtEntitySourceNoCanonicalLinkTest

File

sources/content/tests/src/Functional/ContentTmgmtEntitySourceNoCanonicalLinkTest.php, line 15

Namespace

Drupal\Tests\tmgmt_content\Functional
View source
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.');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentTmgmtEntitySourceNoCanonicalLinkTest::$modules protected static property Modules to enable. Overrides TMGMTTestBase::$modules
ContentTmgmtEntitySourceNoCanonicalLinkTest::setUp function Overrides DrupalWebTestCase::setUp() Overrides TMGMTTestBase::setUp
ContentTmgmtEntitySourceNoCanonicalLinkTest::testNoCanonicalLinkTemplate public function Tests for no canonical link templates.
TmgmtEntityTestTrait::$field_names public property
TmgmtEntityTestTrait::attachFields function Creates fields of type text and text_with_summary of different cardinality.
TmgmtEntityTestTrait::createNodeType function Creates node type with several text fields with different cardinality.
TmgmtEntityTestTrait::createTaxonomyTerm function Creates a taxonomy term of a given vocabulary.
TmgmtEntityTestTrait::createTaxonomyVocab function Creates taxonomy vocabulary with custom fields.
TmgmtEntityTestTrait::createTranslatableNode protected function Creates a node of a given bundle.
TMGMTTestBase::$defaultTheme protected property
TMGMTTestBase::$default_translator protected property A default translator using the test translator.
TmgmtTestTrait::$admin_permissions protected property List of permissions used by loginAsAdmin().
TmgmtTestTrait::$admin_user protected property Drupal user object created by loginAsAdmin().
TmgmtTestTrait::$languageWeight protected property The language weight for new languages.
TmgmtTestTrait::$translator_permissions protected property List of permissions used by loginAsTranslator().
TmgmtTestTrait::$translator_user protected property Drupal user object created by loginAsTranslator().
TmgmtTestTrait::addLanguage function Sets the proper environment.
TmgmtTestTrait::assertJobItemLangCodes function Asserts job item language codes.
TmgmtTestTrait::assertTextByXpath protected function Asserts text in the page with an xpath expression.
TmgmtTestTrait::clickLinkWithImageTitle function Clicks on an image link with the provided title attribute.
TmgmtTestTrait::createJob function Creates, saves and returns a translation job.
TmgmtTestTrait::createTranslator function Creates, saves and returns a translator.
TmgmtTestTrait::loginAsAdmin function Will create a user with admin permissions and log it in.
TmgmtTestTrait::loginAsTranslator function Will create a user with translator permissions and log it in.