Pull merge.
[yaffs-website] / web / core / modules / aggregator / tests / src / Functional / DeleteFeedTest.php
1 <?php
2
3 namespace Drupal\Tests\aggregator\Functional;
4
5 /**
6  * Delete feed test.
7  *
8  * @group aggregator
9  */
10 class DeleteFeedTest extends AggregatorTestBase {
11
12   /**
13    * Modules to install.
14    *
15    * @var array
16    */
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     $feed1 = $this->createFeed();
24     $feed2 = $this->createFeed();
25
26     // Place a block for both feeds.
27     $block = $this->drupalPlaceBlock('aggregator_feed_block');
28     $block->getPlugin()->setConfigurationValue('feed', $feed1->id());
29     $block->save();
30     $block2 = $this->drupalPlaceBlock('aggregator_feed_block');
31     $block2->getPlugin()->setConfigurationValue('feed', $feed2->id());
32     $block2->save();
33
34     // Delete feed.
35     $this->deleteFeed($feed1);
36     $this->assertText($feed2->label());
37     $block_storage = $this->container->get('entity.manager')->getStorage('block');
38     $this->assertNull($block_storage->load($block->id()), 'Block for the deleted feed was deleted.');
39     $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     $result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed1->label())->condition('url', $feed1->getUrl())->count()->execute();
47     $this->assertEquals(0, $result, 'Feed not found in database');
48   }
49
50 }