DeleteFeedTest.php in Drupal 8
File
core/modules/aggregator/tests/src/Functional/DeleteFeedTest.php
View source
<?php
namespace Drupal\Tests\aggregator\Functional;
class DeleteFeedTest extends AggregatorTestBase {
public static $modules = [
'block',
];
protected $defaultTheme = 'stark';
public function testDeleteFeed() {
$feed1 = $this
->createFeed();
$feed2 = $this
->createFeed();
$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();
$this
->deleteFeed($feed1);
$this
->assertText($feed2
->label());
$block_storage = $this->container
->get('entity_type.manager')
->getStorage('block');
$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.');
$this
->drupalGet('aggregator/sources/' . $feed1
->id());
$this
->assertSession()
->statusCodeEquals(404);
$result = \Drupal::entityQuery('aggregator_feed')
->condition('title', $feed1
->label())
->condition('url', $feed1
->getUrl())
->count()
->execute();
$this
->assertEquals(0, $result, 'Feed not found in database');
}
}