DeleteFeedTest.php 1.57 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\aggregator\Functional;
4

5
/**
6 7 8
 * Delete feed test.
 *
 * @group aggregator
9
 */
10
class DeleteFeedTest extends AggregatorTestBase {
11 12

  /**
13
   * Modules to install.
14 15 16
   *
   * @var array
   */
17
  public static $modules = ['block'];
18

19
  /**
20
   * Deletes a feed and ensures that all of its services are deleted.
21
   */
22
  public function testDeleteFeed() {
23 24 25 26 27 28 29 30 31 32
    $feed1 = $this->createFeed();
    $feed2 = $this->createFeed();

    // Place a block for both feeds.
    $block = $this->drupalPlaceBlock('aggregator_feed_block');
    $block->getPlugin()->setConfigurationValue('feed', $feed1->id());
    $block->save();
    $block2 = $this->drupalPlaceBlock('aggregator_feed_block');
    $block2->getPlugin()->setConfigurationValue('feed', $feed2->id());
    $block2->save();
33 34

    // Delete feed.
35 36
    $this->deleteFeed($feed1);
    $this->assertText($feed2->label());
37
    $block_storage = $this->container->get('entity_type.manager')->getStorage('block');
38 39
    $this->assertNull($block_storage->load($block->id()), 'Block for the deleted feed was deleted.');
    $this->assertEqual($block2->id(), $block_storage->load($block2->id())->id(), 'Block for not deleted feed still exists.');
40 41

    // Check feed source.
42
    $this->drupalGet('aggregator/sources/' . $feed1->id());
43
    $this->assertResponse(404, 'Deleted feed source does not exist.');
44 45

    // Check database for feed.
46 47
    $result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed1->label())->condition('url', $feed1->getUrl())->count()->execute();
    $this->assertEquals(0, $result, 'Feed not found in database');
48
  }
49

50
}