You are here

public function LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  2. 4.0.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  3. 3.0.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  4. 3.1.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  5. 3.2.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  6. 3.3.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  7. 3.4.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  8. 3.5.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  9. 3.7.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()
  10. 3.8.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testNeedsUploadSourceStatusFilter()

Tests if the "Needs Upload" source status filter works in combination with other filters.

File

tests/src/Functional/Form/LingotekNodeBulkFormTest.php, line 2327

Class

LingotekNodeBulkFormTest
Tests the bulk management form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testNeedsUploadSourceStatusFilter() {

  // Add a language.
  ConfigurableLanguage::createFromLangcode('de')
    ->setThirdPartySetting('lingotek', 'locale', 'de_DE')
    ->save();
  $this
    ->saveLingotekContentTranslationSettingsForNodeTypes([
    'article',
    'custom_type',
  ], 'manual');
  $node_defaults = [
    'type' => 'article',
    'langcode' => 'en',
  ];

  /** @var \Drupal\node\Entity\Node[] $nodes */
  $nodes = [
    Node::create([
      'title' => 'CustomType edited ready ready',
      'type' => 'custom_type',
    ] + $node_defaults),
    Node::create([
      'title' => 'Article current error current',
    ] + $node_defaults),
    Node::create([
      'title' => 'Article importing null null',
    ] + $node_defaults),
    Node::create([
      'title' => 'Article null null null',
    ] + $node_defaults),
    Node::create([
      'title' => 'CustomType edited current edited',
      'type' => 'custom_type',
    ] + $node_defaults),
    Node::create([
      'title' => 'CustomType edited edited current',
      'type' => 'custom_type',
      'langcode' => 'de',
    ] + $node_defaults),
    Node::create([
      'title' => 'Article error edited ready',
    ] + $node_defaults),
    Node::create([
      'title' => 'Article current interim ready',
    ] + $node_defaults),
    Node::create([
      'title' => 'CustomType error null null',
      'type' => 'custom_type',
    ] + $node_defaults),
    Node::create([
      'title' => 'CustomType current current ready',
      'type' => 'custom_type',
    ] + $node_defaults),
    Node::create([
      'title' => 'Article cancelled cancelled cancelled',
    ] + $node_defaults),
  ];
  foreach ($nodes as $node) {
    $node
      ->save();
  }
  $metadata_defaults = [
    'profile' => 'automatic',
    'translation_source' => 'en',
  ];
  $metadatas = [
    [
      'profile' => 'manual',
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'edited',
        ],
        [
          'language' => 'de',
          'value' => 'ready',
        ],
        [
          'language' => 'es',
          'value' => 'ready',
        ],
      ],
    ] + $metadata_defaults,
    [
      'profile' => 'manual',
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'current',
        ],
        [
          'language' => 'de',
          'value' => 'error',
        ],
        [
          'language' => 'es',
          'value' => 'current',
        ],
      ],
    ] + $metadata_defaults,
    [
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'importing',
        ],
      ],
    ] + $metadata_defaults,
    [
      'translation_status' => [],
    ] + $metadata_defaults,
    [
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'edited',
        ],
        [
          'language' => 'de',
          'value' => 'current',
        ],
        [
          'language' => 'es',
          'value' => 'edited',
        ],
      ],
    ] + $metadata_defaults,
    [
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'edited',
        ],
        [
          'language' => 'de',
          'value' => 'edited',
        ],
        [
          'language' => 'es',
          'value' => 'current',
        ],
      ],
    ] + $metadata_defaults,
    [
      'profile' => 'manual',
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'error',
        ],
        [
          'language' => 'de',
          'value' => 'edited',
        ],
        [
          'language' => 'es',
          'value' => 'ready',
        ],
      ],
    ] + $metadata_defaults,
    [
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'current',
        ],
        [
          'language' => 'de',
          'value' => 'interim',
        ],
        [
          'language' => 'es',
          'value' => 'ready',
        ],
      ],
    ] + $metadata_defaults,
    [
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'error',
        ],
      ],
    ] + $metadata_defaults,
    [
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'current',
        ],
        [
          'language' => 'de',
          'value' => 'current',
        ],
        [
          'language' => 'es',
          'value' => 'ready',
        ],
      ],
    ] + $metadata_defaults,
    [
      'translation_status' => [
        [
          'language' => 'en',
          'value' => 'cancelled',
        ],
        [
          'language' => 'de',
          'value' => 'cancelled',
        ],
        [
          'language' => 'es',
          'value' => 'cancelled',
        ],
      ],
    ] + $metadata_defaults,
  ];
  $index = 0;
  foreach ($metadatas as $metadata_data) {
    ++$index;
    $metadata = LingotekContentMetadata::loadByTargetId('node', $index);
    $metadata
      ->setDocumentId('document_id_' . $index);
    $metadata
      ->set('translation_status', $metadata_data['translation_status']);
    $metadata
      ->set('profile', $metadata_data['profile']);
    $metadata
      ->set('translation_source', $metadata_data['translation_source']);
    $metadata
      ->save();
  }
  Node::create([
    'title' => 'CustomType nothing nothing nothing',
    'type' => 'custom_type',
  ] + $node_defaults)
    ->save();
  Node::create([
    'title' => 'NotConfigured nothing nothing nothing',
    'type' => 'not_configured',
  ] + $node_defaults)
    ->save();
  $this
    ->assertEquals(12, count(LingotekContentMetadata::loadMultiple()));
  $this
    ->goToContentBulkManagementForm();
  $this
    ->assertText('CustomType edited ready ready');
  $this
    ->assertText('Article current error current');
  $this
    ->assertText('Article importing null null');
  $this
    ->assertText('Article null null null');
  $this
    ->assertText('CustomType edited current edited');
  $this
    ->assertText('CustomType edited edited current');
  $this
    ->assertText('Article error edited ready');
  $this
    ->assertText('Article current interim ready');
  $this
    ->assertText('CustomType error null null');
  $this
    ->assertText('CustomType current current ready');
  $this
    ->assertNoText('CustomType nothing nothing nothing');
  $this
    ->assertNoText('NotConfigured nothing nothing nothing');
  $this
    ->assertNoText('Article cancelled cancelled cancelled');

  // Change page limit
  \Drupal::service('tempstore.private')
    ->get('lingotek.management.items_per_page')
    ->set('limit', 50);
  $this
    ->goToContentBulkManagementForm();
  $this
    ->assertText('CustomType edited ready ready');
  $this
    ->assertText('Article current error current');
  $this
    ->assertText('Article importing null null');
  $this
    ->assertText('Article null null null');
  $this
    ->assertText('CustomType edited current edited');
  $this
    ->assertText('CustomType edited edited current');
  $this
    ->assertText('Article error edited ready');
  $this
    ->assertText('Article current interim ready');
  $this
    ->assertText('CustomType error null null');
  $this
    ->assertText('CustomType current current ready');
  $this
    ->assertText('CustomType nothing nothing nothing');
  $this
    ->assertText('NotConfigured nothing nothing nothing');
  $this
    ->assertText('Article cancelled cancelled cancelled');
  $edit = [
    'filters[advanced_options][source_status]' => 'UPLOAD_NEEDED',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
  $this
    ->assertText('CustomType edited ready ready');
  $this
    ->assertNoText('Article current error current');
  $this
    ->assertNoText('Article importing null null');
  $this
    ->assertText('Article null null null');
  $this
    ->assertText('CustomType edited current edited');
  $this
    ->assertText('CustomType edited edited current');
  $this
    ->assertText('Article error edited ready');
  $this
    ->assertNoText('Article current interim ready');
  $this
    ->assertText('CustomType error null null');
  $this
    ->assertNoText('CustomType current current ready');
  $this
    ->assertText('CustomType nothing nothing nothing');
  $this
    ->assertText('NotConfigured nothing nothing nothing');
  $this
    ->assertText('Article cancelled cancelled cancelled');
  $edit = [
    'filters[advanced_options][source_status]' => 'UPLOAD_NEEDED',
    'filters[wrapper][bundle][]' => [
      'custom_type',
      'not_configured',
    ],
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
  $this
    ->assertText('CustomType edited ready ready');
  $this
    ->assertNoText('Article current error current');
  $this
    ->assertNoText('Article importing null null');
  $this
    ->assertNoText('Article null null null');
  $this
    ->assertText('CustomType edited current edited');
  $this
    ->assertText('CustomType edited edited current');
  $this
    ->assertNoText('Article error edited ready');
  $this
    ->assertNoText('Article current interim ready');
  $this
    ->assertText('CustomType error null null');
  $this
    ->assertNoText('CustomType current current ready');
  $this
    ->assertText('CustomType nothing nothing nothing');
  $this
    ->assertText('NotConfigured nothing nothing nothing');
  $this
    ->assertNoText('Article cancelled cancelled cancelled');
  $edit = [
    'filters[advanced_options][source_status]' => 'UPLOAD_NEEDED',
    'filters[wrapper][bundle][]' => [
      'custom_type',
      'not_configured',
    ],
    'filters[advanced_options][source_language]' => 'en',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
  $this
    ->assertText('CustomType edited ready ready');
  $this
    ->assertNoText('Article current error current');
  $this
    ->assertNoText('Article importing null null');
  $this
    ->assertNoText('Article null null null');
  $this
    ->assertText('CustomType edited current edited');
  $this
    ->assertNoText('CustomType edited edited current');
  $this
    ->assertNoText('Article error edited ready');
  $this
    ->assertNoText('Article current interim ready');
  $this
    ->assertText('CustomType error null null');
  $this
    ->assertNoText('CustomType current current ready');
  $this
    ->assertText('CustomType nothing nothing nothing');
  $this
    ->assertText('NotConfigured nothing nothing nothing');
  $this
    ->assertNoText('Article cancelled cancelled cancelled');
  $edit = [
    'filters[advanced_options][source_status]' => 'UPLOAD_NEEDED',
    'filters[wrapper][bundle][]' => [
      'custom_type',
      'not_configured',
    ],
    'filters[advanced_options][source_language]' => 'en',
    'filters[advanced_options][profile][]' => [
      'manual',
      'automatic',
    ],
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
  $this
    ->assertText('CustomType edited ready ready');
  $this
    ->assertNoText('Article current error current');
  $this
    ->assertNoText('Article importing null null');
  $this
    ->assertNoText('Article null null null');
  $this
    ->assertText('CustomType edited current edited');
  $this
    ->assertNoText('CustomType edited edited current');
  $this
    ->assertNoText('Article error edited ready');
  $this
    ->assertNoText('Article current interim ready');
  $this
    ->assertText('CustomType error null null');
  $this
    ->assertNoText('CustomType current current ready');
  $this
    ->assertNoText('CustomType nothing nothing nothing');
  $this
    ->assertNoText('NotConfigured nothing nothing nothing');
  $this
    ->assertNoText('Article cancelled cancelled cancelled');
  $edit = [
    'filters[advanced_options][source_status]' => 'UPLOAD_NEEDED',
    'filters[wrapper][bundle][]' => [
      'custom_type',
      'not_configured',
    ],
    'filters[advanced_options][source_language]' => 'en',
    'filters[advanced_options][profile][]' => [
      'manual',
      'automatic',
    ],
    'filters[advanced_options][target_status]' => 'READY',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
  $this
    ->assertText('CustomType edited ready ready');
  $this
    ->assertNoText('Article current error current');
  $this
    ->assertNoText('Article importing null null');
  $this
    ->assertNoText('Article null null null');
  $this
    ->assertNoText('CustomType edited current edited');
  $this
    ->assertNoText('CustomType edited edited current');
  $this
    ->assertNoText('Article error edited ready');
  $this
    ->assertNoText('Article current interim ready');
  $this
    ->assertNoText('CustomType error null null');
  $this
    ->assertNoText('CustomType current current ready');
  $this
    ->assertNoText('CustomType nothing nothing nothing');
  $this
    ->assertNoText('NotConfigured nothing nothing nothing');
  $this
    ->assertNoText('Article cancelled cancelled cancelled');
}