You are here

public function UiCrudTest::testRemoveTamperInstance in Feeds Tamper 8.2

Tests removing a Tamper plugin using the UI.

File

tests/src/Functional/UiCrudTest.php, line 148

Class

UiCrudTest
Tests adding/editing/removing tamper plugins using the UI.

Namespace

Drupal\Tests\feeds_tamper\Functional

Code

public function testRemoveTamperInstance() {

  // Programmatically add a tamper plugin instance.
  $this->feedTypeTamperManager
    ->getTamperMeta($this->feedType, TRUE)
    ->addTamper([
    'plugin' => 'convert_case',
    'operation' => 'strtoupper',
    'label' => 'Str to Upper',
    'source' => 'title',
    'description' => 'Convert the case to uppercase.',
  ]);
  $this->feedType
    ->save();

  // Go to the tamper listing.
  $this
    ->drupalGet($this->url);

  // Click link for removing this tamper plugin.
  $this
    ->getSession()
    ->getPage()
    ->find('css', '#edit-title ul.dropbutton li:nth-child(2) a')
    ->click();

  // Confirm.
  $this
    ->submitForm([], 'Confirm');

  // Assert that the tamper instance was removed.
  $this->feedType = $this
    ->reloadEntity($this->feedType);
  $plugin_collection = $this->feedTypeTamperManager
    ->getTamperMeta($this->feedType, TRUE)
    ->getTampers();
  $this
    ->assertCount(0, $plugin_collection);
}