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 TranslatorUITest

Tests the translator add, edit and overview user interfaces.

@group tmgmt

Hierarchy

Expanded class hierarchy of TranslatorUITest

File

tests/src/Functional/TranslatorUITest.php, line 10

Namespace

Drupal\Tests\tmgmt\Functional
View source
class TranslatorUITest extends TMGMTTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  protected static $modules = array(
    'tmgmt_file',
  );

  /**
   * {@inheritdoc}
   */
  function setUp() : void {
    parent::setUp();

    // Login as administrator to add/edit and view translators.
    $this
      ->loginAsAdmin();
  }

  /**
   * Tests UI for creating a translator.
   */
  public function testTranslatorUI() {

    // Test translator creation UI.
    $this
      ->drupalGet('admin/tmgmt/translators/add');
    $this
      ->submitForm([
      'label' => 'Test translator',
      'description' => 'Test translator description',
      'name' => 'translator_test',
      'settings[scheme]' => 'private',
    ], 'Save');
    $this
      ->assertSession()
      ->pageTextContains('Test translator configuration has been created.');

    // Test translator edit page.
    $this
      ->drupalGet('admin/tmgmt/translators/manage/translator_test');
    $this
      ->assertSession()
      ->fieldValueEquals('label', 'Test translator');
    $this
      ->assertSession()
      ->fieldValueEquals('description', 'Test translator description');
    $this
      ->assertSession()
      ->fieldValueEquals('name', 'translator_test');
    $this
      ->assertSession()
      ->checkboxChecked('edit-settings-scheme-private');
    $this
      ->submitForm([
      'label' => 'Test translator changed',
      'description' => 'Test translator description changed',
    ], 'Save');
    $this
      ->assertSession()
      ->pageTextContains('Test translator changed configuration has been updated.');

    // Test translator overview page.
    $this
      ->drupalGet('admin/tmgmt/translators');
    $this
      ->assertSession()
      ->responseContains('<img class="tmgmt-logo-overview"');
    $this
      ->assertSession()
      ->pageTextContains('Test translator changed');
    $this
      ->assertSession()
      ->linkExists('Edit');
    $this
      ->assertSession()
      ->linkExists('Delete');

    // Check if the edit link is displayed before the clone link.
    $content = $this
      ->assertSession()
      ->elementExists('css', '.dropbutton-wrapper')
      ->getHtml();
    $edit_position = strpos($content, 'Edit');
    $clone_position = strpos($content, 'Clone');
    $this
      ->assertTrue($edit_position < $clone_position);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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.
TranslatorUITest::$modules protected static property Modules to enable. Overrides TMGMTTestBase::$modules
TranslatorUITest::setUp function Overrides DrupalWebTestCase::setUp() Overrides TMGMTTestBase::setUp
TranslatorUITest::testTranslatorUI public function Tests UI for creating a translator.