Backup of db before drupal security update
[yaffs-website] / web / core / modules / aggregator / src / Tests / UpdateFeedTest.php
1 <?php
2
3 namespace Drupal\aggregator\Tests;
4
5 /**
6  * Update feed test.
7  *
8  * @group aggregator
9  */
10 class UpdateFeedTest extends AggregatorTestBase {
11   /**
12    * Creates a feed and attempts to update it.
13    */
14   public function testUpdateFeed() {
15     $remaining_fields = ['title[0][value]', 'url[0][value]', ''];
16     foreach ($remaining_fields as $same_field) {
17       $feed = $this->createFeed();
18
19       // Get new feed data array and modify newly created feed.
20       $edit = $this->getFeedEditArray();
21       // Change refresh value.
22       $edit['refresh'] = 1800;
23       if (isset($feed->{$same_field}->value)) {
24         $edit[$same_field] = $feed->{$same_field}->value;
25       }
26       $this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, t('Save'));
27       $this->assertText(t('The feed @name has been updated.', ['@name' => $edit['title[0][value]']]), format_string('The feed %name has been updated.', ['%name' => $edit['title[0][value]']]));
28
29       // Verify that the creation message contains a link to a feed.
30       $view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']);
31       $this->assert(isset($view_link), 'The message area contains a link to a feed');
32
33       // Check feed data.
34       $this->assertUrl($feed->url('canonical', ['absolute' => TRUE]));
35       $this->assertTrue($this->uniqueFeed($edit['title[0][value]'], $edit['url[0][value]']), 'The feed is unique.');
36
37       // Check feed source.
38       $this->drupalGet('aggregator/sources/' . $feed->id());
39       $this->assertResponse(200, 'Feed source exists.');
40       $this->assertText($edit['title[0][value]'], 'Page title');
41
42       // Set correct title so deleteFeed() will work.
43       $feed->title = $edit['title[0][value]'];
44
45       // Delete feed.
46       $this->deleteFeed($feed);
47     }
48   }
49
50 }