View source
<?php
namespace Drupal\Tests\feeds_tamper\Functional;
class FeedTypeListBuilderTest extends FeedsTamperBrowserTestBase {
public function testUiWithRestrictedPrivileges() {
$this->feedType = $this
->createFeedType([
'id' => 'my_feed_type',
'label' => 'My feed type',
]);
$this->feedType = $this
->createFeedType([
'id' => 'my_feed_type_restricted',
'label' => 'My feed type (restricted)',
]);
$account = $this
->drupalCreateUser([
'administer feeds',
'tamper my_feed_type',
]);
$this
->drupalLogin($account);
$this
->drupalGet('/admin/structure/feeds');
$session = $this
->assertSession();
$session
->linkExists('Tamper');
$session
->linkByHrefExists('/admin/structure/feeds/manage/my_feed_type/tamper');
$session
->linkByHrefNotExists('/admin/structure/feeds/manage/my_feed_type_restricted/tamper');
}
public function testDeltaIncreaseWithManyTampers() {
$feed_type_tamper_manager = $this->container
->get('feeds_tamper.feed_type_tamper_manager');
$feed_type = $this
->createFeedType([
'id' => 'my_feed_type',
'label' => 'My feed type',
]);
$uuid = $feed_type_tamper_manager
->getTamperMeta($feed_type)
->addTamper([
'plugin' => 'convert_case',
'operation' => 'strtoupper',
'source' => 'title',
'description' => 'Convert the case to uppercase.',
]);
$feed_type
->save();
$this
->drupalGet('/admin/structure/feeds/manage/my_feed_type/tamper');
$weight_selector = $this
->getSession()
->getPage()
->find('css', '#edit-title-' . $uuid . '-weight');
$this
->assertEquals(implode('', range(-10, 10)), $weight_selector
->getText());
for ($i = 0; $i < 19; $i++) {
$feed_type_tamper_manager
->getTamperMeta($feed_type)
->addTamper([
'plugin' => 'convert_case',
'operation' => 'strtoupper',
'source' => 'title',
'description' => 'Convert the case to uppercase.',
]);
}
$feed_type
->save();
$this
->drupalGet('/admin/structure/feeds/manage/my_feed_type/tamper');
$weight_selector = $this
->getSession()
->getPage()
->find('css', '#edit-title-' . $uuid . '-weight');
$this
->assertEquals(implode('', range(-10, 10)), $weight_selector
->getText());
for ($i = 0; $i < 2; $i++) {
$feed_type_tamper_manager
->getTamperMeta($feed_type)
->addTamper([
'plugin' => 'convert_case',
'operation' => 'strtoupper',
'source' => 'title',
'description' => 'Convert the case to uppercase.',
]);
}
$feed_type
->save();
$this
->drupalGet('/admin/structure/feeds/manage/my_feed_type/tamper');
$weight_selector = $this
->getSession()
->getPage()
->find('css', '#edit-title-' . $uuid . '-weight');
$this
->assertEquals(implode('', range(-11, 11)), $weight_selector
->getText());
}
}