public function UiCrudTest::testLabelUpdateWhenChangingPlugin in Feeds Tamper 8.2
Tests that the label gets updated when selecting an other plugin.
File
- tests/src/ FunctionalJavascript/ UiCrudTest.php, line 104 
Class
- UiCrudTest
- Tests adding/editing/removing tamper plugins using the UI.
Namespace
Drupal\Tests\feeds_tamper\FunctionalJavascriptCode
public function testLabelUpdateWhenChangingPlugin() {
  // Go to the tamper listing.
  $this
    ->drupalGet($this->url);
  // Click link for adding a tamper plugin to the source 'description'.
  $this
    ->getSession()
    ->getPage()
    ->find('css', '#edit-description-add-link')
    ->click();
  // Select plugin and wait for config form to show up.
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->selectFieldOption('tamper_id', 'required');
  $this
    ->assertSession()
    ->waitForElementVisible('css', '#plugin-config');
  // Assert that the label got set to 'Required'.
  $field = $page
    ->findField('plugin_configuration[label]');
  $this
    ->assertEquals('Required', $field
    ->getValue());
  // Now select an other plugin.
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->selectFieldOption('tamper_id', 'unique');
  // We use waitForText() here because '#plugin-config' is already visible.
  $this
    ->assertSession()
    ->waitForText('Makes the elements in a multivalued field unique.');
  // Assert that the label changed to 'Unique'.
  $field = $page
    ->findField('plugin_configuration[label]');
  $this
    ->assertEquals('Unique', $field
    ->getValue());
  // And save.
  $this
    ->submitForm([], 'Submit');
  // And assert that the tamper plugin was added.
  $this->feedType = $this
    ->reloadEntity($this->feedType);
  $plugin_collection = $this->feedTypeTamperManager
    ->getTamperMeta($this->feedType, TRUE)
    ->getTampers();
  $this
    ->assertCount(1, $plugin_collection);
  $tamper = $plugin_collection
    ->getIterator()
    ->current();
  $this
    ->assertEquals('unique', $tamper
    ->getPluginId());
  $this
    ->assertEquals('Unique', $tamper
    ->getSetting('label'));
  $this
    ->assertEquals('description', $tamper
    ->getSetting('source'));
  // Assert that no PHP errors were generated.
  $this
    ->assertNoPhpErrorsInLog();
}