You are here

public function FeedDeleteTest::testOrphanedFeedDelete in Feeds 8.3

Tests deleting a feed whose feed type no longer exists.

File

tests/src/Functional/FeedDeleteTest.php, line 71

Class

FeedDeleteTest
Tests deleting a feed using the UI.

Namespace

Drupal\Tests\feeds\Functional

Code

public function testOrphanedFeedDelete() {

  // Add a feed type.
  $feed_type = $this
    ->createFeedType();

  // Add a feed.
  $feed = $this
    ->createFeed($feed_type
    ->id(), [
    'source' => $this
      ->resourcesPath() . '/rss/googlenewstz.rss2',
  ]);

  // Programmatically delete the feed type. The feed is now orphaned.
  $feed_type
    ->delete();

  // Now try to delete this feed.
  $this
    ->drupalPostForm('/feed/1/delete', [], 'Delete');

  // Ensure that no errors are shown.
  $this
    ->assertSession()
    ->pageTextNotContains('The website encountered an unexpected error.');

  // Ensure that the feed now no longer exists.
  $this
    ->assertNull($this
    ->reloadEntity($feed));
}