public function UiCrudTest::testChangeTamperOrder in Feeds Tamper 8.2
Tests changing weights of Tamper plugins.
File
- tests/
src/ Functional/ UiCrudTest.php, line 184
Class
- UiCrudTest
- Tests adding/editing/removing tamper plugins using the UI.
Namespace
Drupal\Tests\feeds_tamper\FunctionalCode
public function testChangeTamperOrder() {
// Programmatically add a few tamper plugin instances.
$tamper_meta = $this->feedTypeTamperManager
->getTamperMeta($this->feedType, TRUE);
$uuid_content_1 = $tamper_meta
->addTamper([
'plugin' => 'explode',
'label' => 'Explode',
'separator' => '|',
'source' => 'content',
]);
$uuid_content_2 = $tamper_meta
->addTamper([
'plugin' => 'implode',
'label' => 'Implode',
'glue' => '-',
'source' => 'content',
]);
$uuid_content_3 = $tamper_meta
->addTamper([
'plugin' => 'trim',
'label' => 'Trim Content',
'side' => 'trim',
'source' => 'content',
]);
$uuid_title_1 = $tamper_meta
->addTamper([
'plugin' => 'trim',
'label' => 'Trim Title',
'side' => 'trim',
'source' => 'title',
]);
$uuid_title_2 = $tamper_meta
->addTamper([
'plugin' => 'required',
'label' => 'Required',
'invert' => FALSE,
'source' => 'title',
]);
$this->feedType
->save();
// Go to the tamper listing.
$this
->drupalGet($this->url);
// Change weights.
$edit = [
"title[{$uuid_title_1}][weight]" => -9,
"title[{$uuid_title_2}][weight]" => -10,
"content[{$uuid_content_1}][weight]" => -10,
"content[{$uuid_content_2}][weight]" => -8,
"content[{$uuid_content_3}][weight]" => -9,
];
$this
->submitForm($edit, 'Save');
// Assert that the weights of all tamper plugins were updated.
$this->feedType = $this
->reloadEntity($this->feedType);
$tamper_meta = $this->feedTypeTamperManager
->getTamperMeta($this->feedType, TRUE);
$this
->assertEquals(-9, $tamper_meta
->getTamper($uuid_title_1)
->getSetting('weight'));
$this
->assertEquals(-10, $tamper_meta
->getTamper($uuid_title_2)
->getSetting('weight'));
$this
->assertEquals(-10, $tamper_meta
->getTamper($uuid_content_1)
->getSetting('weight'));
$this
->assertEquals(-8, $tamper_meta
->getTamper($uuid_content_2)
->getSetting('weight'));
$this
->assertEquals(-9, $tamper_meta
->getTamper($uuid_content_3)
->getSetting('weight'));
}