DeleteFeedTest.php in Feeds 8.3
File
tests/src/Functional/Plugin/Action/DeleteFeedTest.php
View source
<?php
namespace Drupal\Tests\feeds\Functional\Plugin\Action;
use Drupal\feeds\Entity\Feed;
use Drupal\Tests\feeds\Functional\FeedsBrowserTestBase;
class DeleteFeedTest extends FeedsBrowserTestBase {
public static $modules = [
'feeds',
'node',
'user',
'file',
'views',
];
public function test() {
$feed_type = $this
->createFeedType();
for ($i = 1; $i <= 3; $i++) {
$this
->createFeed($feed_type
->id(), [
'title' => 'My feed ' . $i,
'source' => $this
->resourcesUrl() . '/rss/googlenewstz.rss2',
]);
}
$this
->drupalGet('admin/content/feed');
$edit = [];
for ($i = 0; $i < 2; $i++) {
$this
->assertFieldById('edit-feeds-feed-bulk-form-' . $i);
$edit["feeds_feed_bulk_form[{$i}]"] = TRUE;
}
$edit += [
'action' => 'feeds_feed_delete_action',
];
$this
->drupalPostForm(NULL, $edit, 'Apply to selected items');
$this
->assertSession()
->pageTextContains('Are you sure you want to delete these items?');
$this
->drupalPostForm(NULL, [], 'Delete');
$this
->assertNull(Feed::load(1));
$this
->assertNull(Feed::load(2));
$this
->assertInstanceOf(Feed::class, Feed::load(3));
$this
->assertSession()
->pageTextContains('Deleted 2 feeds.');
}
}