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