You are here

public function LingotekNodeBulkFormTest::testBulkPager in Lingotek Translation 8

Tests that the bulk management pager works correctly.

File

src/Tests/Form/LingotekNodeBulkFormTest.php, line 67

Class

LingotekNodeBulkFormTest
Tests the bulk management form.

Namespace

Drupal\lingotek\Tests\Form

Code

public function testBulkPager() {

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);
  $nodes = [];

  // Create a node.
  for ($i = 1; $i < 15; $i++) {
    $edit = array();
    $edit['title[0][value]'] = 'Llamas are cool ' . $i;
    $edit['body[0][value]'] = 'Llamas are very cool ' . $i;
    $edit['langcode[0][value]'] = 'en';
    $edit['lingotek_translation_profile'] = 'manual';
    $this
      ->drupalPostForm('node/add/article', $edit, t('Save and publish'));
    $nodes[$i] = $edit;
  }
  $this
    ->goToContentBulkManagementForm();

  // Navigate to page 2.
  $this
    ->clickLink(t('Page 2'));
  $this
    ->assertUrl('admin/lingotek/manage/node?page=1');
  $basepath = \Drupal::request()
    ->getBasePath();

  // I can init the upload of content.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/entity/upload/node/11?destination=' . $basepath . '/admin/lingotek/manage/node');
  $edit = [
    // Node 11.
    'table[11]' => TRUE,
    // Node 12.
    'table[12]' => TRUE,
    'operation' => 'upload',
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Execute'));

  // The current page is kept.
  $this
    ->assertUrl('admin/lingotek/manage/node?page=1');

  // There is a link for checking status.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/entity/check_upload/dummy-document-hash-id?destination=' . $basepath . '/admin/lingotek/manage/node');

  // And we can already request a translation.
  $this
    ->assertLinkByHref($basepath . '/admin/lingotek/entity/add_target/dummy-document-hash-id/es_MX?destination=' . $basepath . '/admin/lingotek/manage/node');
  $this
    ->clickLink('EN');
  $this
    ->assertText('The import for node Llamas are cool 11 is complete.');

  // The current page is kept.
  $this
    ->assertUrl('admin/lingotek/manage/node?page=1');
}