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 LocalTasksTests

Verifies basic functionality of the local tasks.

@group tmgmt

Hierarchy

Expanded class hierarchy of LocalTasksTests

File

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

Namespace

Drupal\Tests\tmgmt\Functional
View source
class LocalTasksTests extends TMGMTTestBase {
  protected static $modules = array(
    'dblog',
    'node',
    'views',
    'tmgmt_content',
    'tmgmt_file',
    'tmgmt_config',
  );

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

    // Login as administrator to view Cart,Jobs and Sources.
    $this
      ->loginAsAdmin(array(
      'access administration pages',
    ));
  }

  /**
   * Tests UI for translator local tasks.
   */
  public function testTranslatorLocalTasks() {
    $this
      ->drupalCreateContentType(array(
      'type' => 'article',
      'name' => 'Article',
    ));
    $content_translation_manager = \Drupal::service('content_translation.manager');

    // Add a node type and enable translation for nodes and users.
    $content_translation_manager
      ->setEnabled('node', 'article', TRUE);
    $content_translation_manager
      ->setEnabled('user', 'user', TRUE);
    drupal_static_reset();
    \Drupal::entityTypeManager()
      ->clearCachedDefinitions();
    \Drupal::service('router.builder')
      ->rebuild();
    \Drupal::service('entity.definition_update_manager')
      ->getChangeList();

    // Check the translator menu link.
    $this
      ->drupalGet('admin');
    $this
      ->clickLink(t('Translation'));

    // Make sure the Cart,Jobs and Sources pages are available.
    $this
      ->clickLink(t('Cart'));
    $this
      ->clickLink(t('Jobs'));
    $this
      ->clickLink(t('Providers'));
    $this
      ->clickLink(t('Settings'));
    $this
      ->clickLink(t('Sources'));

    // Assert the availability of the enabled content.
    $this
      ->assertTrue($this
      ->assertSession()
      ->optionExists('edit-source', 'content:node')
      ->isSelected());
    $this
      ->assertSession()
      ->optionExists('edit-source', 'content:node');
    $this
      ->assertSession()
      ->optionExists('edit-source', 'content:user');
    $this
      ->assertSession()
      ->optionExists('edit-source', 'config:block');
    $this
      ->assertSession()
      ->optionExists('edit-source', 'config:node_type');
    $this
      ->assertSession()
      ->optionExists('edit-source', 'config:tmgmt_translator');
    $this
      ->assertSession()
      ->optionNotExists('edit-source', 'config:base_field_override');
  }

  /**
   * Tests UI for translator local tasks without sources.
   */
  public function testTranslatorLocalTasksNoSource() {

    // Login as administrator to view Cart,Jobs and Sources.
    $this
      ->loginAsAdmin(array(
      'access administration pages',
    ));
    $this
      ->drupalGet('admin');
    $this
      ->clickLink(t('Translation'));
    $this
      ->clickLink(t('Sources'));
    $this
      ->assertSession()
      ->pageTextContains(t('No sources enabled.'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LocalTasksTests::$modules protected static property Modules to enable. Overrides TMGMTTestBase::$modules
LocalTasksTests::setUp public function Overrides DrupalWebTestCase::setUp() Overrides TMGMTTestBase::setUp
LocalTasksTests::testTranslatorLocalTasks public function Tests UI for translator local tasks.
LocalTasksTests::testTranslatorLocalTasksNoSource public function Tests UI for translator local tasks without sources.
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.