function AnnounceFeedTestInvalidJsonTestCase::testInvalidFeedResponse

Test the announcements feed with invalid JSON or non-existing JSON URL.

File

modules/announcements_feed/tests/announce_feed_test.test, line 331

Class

AnnounceFeedTestInvalidJsonTestCase
Tests the announcements feed with invalid JSON URLs.

Code

public function testInvalidFeedResponse() {
    // Test when the JSON URL is not found.
    $this->drupalLogin($this->user);
    $this->drupalGet('');
    $this->clickLink('Announcements');
    variable_set('announcements_feed_json_url', $this->unknownJson);
    cache_clear_all('announcements_feed', 'cache', TRUE);
    $this->drupalGet('admin/announcements_feed');
    $this->assertText('An error occurred while parsing the announcements feed, check the logs for more information.');
    // Test when the JSON feed is invalid.
    $this->drupalLogout();
    $this->drupalLogin($this->user);
    $this->drupalGet('');
    $this->clickLink('Announcements');
    variable_set('announcements_feed_json_url', $this->invalidJson);
    cache_clear_all('announcements_feed', 'cache', TRUE);
    $this->drupalGet('admin/announcements_feed');
    $this->assertText('An error occurred while parsing the announcements feed, check the logs for more information.');
    $this->drupalLogout();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.