Unverified Commit 56b839d7 authored by Mark Dorison's avatar Mark Dorison Committed by Mark Dorison
Browse files

Issue #3288129 by markdorison, Project Update Bot: Automated Drupal 10 compatibility fixes

parent d64babc2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
name: JSON Feed
description: 'Adds support for JSON feeds to Views.'
package: Views
core_version_requirement: ^8.7.7 || ^9
core_version_requirement: ^8.7.7 || ^9 || ^10
type: module
dependencies:
  - drupal:views
+13 −15
Original line number Diff line number Diff line
@@ -76,10 +76,8 @@ class DisplayJsonFeedTest extends ViewTestBase {
  /**
   * {@inheritdoc}
   */
  protected function setUp($import_test_views = TRUE) {
    parent::setUp();

    ViewTestData::createTestViews(get_class($this), ['json_feed_test_views']);
  protected function setUp($import_test_views = TRUE, $modules = ['json_feed_test_views']): void {
    parent::setUp($import_test_views, $modules);

    $admin_user = $this->drupalCreateUser(['administer site configuration'], self::ADMIN_NAME);
    $this->drupalLogin($admin_user);
@@ -107,16 +105,16 @@ class DisplayJsonFeedTest extends ViewTestBase {
   */
  public function testFeedOutput() {
    $json_response = Json::decode($this->drupalGet($this->feedPath, ['query' => ['_format' => 'json']]));
    $this->assertResponse(200);
    $this->assertSession()->statusCodeEquals(200);

    $this->assertTrue(array_key_exists('version', $json_response), 'JSON Feed version present.');
    $this->assertEqual('https://jsonfeed.org/version/1', $json_response['version'], 'JSON Feed version set correctly.');
    $this->assertEquals('https://jsonfeed.org/version/1', $json_response['version'], 'JSON Feed version set correctly.');

    $this->assertTrue(array_key_exists('title', $json_response), 'JSON Feed title present.');
    $this->assertEqual('test_display_json_feed', $json_response['title'], 'JSON Feed title set correctly.');
    $this->assertEquals('test_display_json_feed', $json_response['title'], 'JSON Feed title set correctly.');

    $this->assertTrue(array_key_exists('description', $json_response), 'JSON Feed description present.');
    $this->assertEqual('Test feed description.', $json_response['description'], 'JSON Feed description set correctly.');
    $this->assertEquals('Test feed description.', $json_response['description'], 'JSON Feed description set correctly.');

    $this->assertTrue(array_key_exists('home_page_url', $json_response), 'JSON Feed home_page_url present.');
    // @TODO: Implement test for home_page_url attribute value.
@@ -126,10 +124,10 @@ class DisplayJsonFeedTest extends ViewTestBase {

    $this->assertTrue(array_key_exists('favicon', $json_response), 'JSON Feed favicon present.');
    $favicon_path = Url::fromUserInput(theme_get_setting('favicon.url'))->setAbsolute()->toString();
    $this->assertEqual($favicon_path, $json_response['favicon'], 'JSON Feed favicon set correctly.');
    $this->assertEquals($favicon_path, $json_response['favicon'], 'JSON Feed favicon set correctly.');

    $this->assertTrue(array_key_exists('expired', $json_response), 'JSON Feed expired attribute present.');
    $this->assertEqual(FALSE, $json_response['expired'], 'JSON Feed expired attribute set to FALSE.');
    $this->assertEquals(FALSE, $json_response['expired'], 'JSON Feed expired attribute set to FALSE.');
  }

  /**
@@ -137,7 +135,7 @@ class DisplayJsonFeedTest extends ViewTestBase {
   */
  public function testFeedItems() {
    $json_response = Json::decode($this->drupalGet($this->feedPath, ['query' => ['_format' => 'json']]));
    $this->assertEqual($this->expectedFirstPageItems(), count($json_response['items']), 'JSON Feed returned ' . $this->expectedFirstPageItems() . ' items.');
    $this->assertEquals($this->expectedFirstPageItems(), count($json_response['items']), 'JSON Feed returned ' . $this->expectedFirstPageItems() . ' items.');
    $item = $json_response['items'][0];

    $this->assertTrue(array_key_exists('date_published', $item), 'JSON Feed item date_published attribute present.');
@@ -156,7 +154,7 @@ class DisplayJsonFeedTest extends ViewTestBase {
    $this->assertTrue(array_key_exists('author', $item), 'JSON Feed item author attribute present.');
    $author_info = $item['author'];
    $this->assertTrue(array_key_exists('name', $author_info), 'JSON Feed item author name attribute present.');
    $this->assertEqual(self::ADMIN_NAME, $author_info['name'], 'JSON Feed item author name set correctly.');
    $this->assertEquals(self::ADMIN_NAME, $author_info['name'], 'JSON Feed item author name set correctly.');
  }

  /**
@@ -166,7 +164,7 @@ class DisplayJsonFeedTest extends ViewTestBase {
    $json_response = Json::decode($this->drupalGet($this->feedPath, ['query' => ['_format' => 'json']]));
    array_walk_recursive($json_response, function ($item, $key) {
      if (!is_array($item) && !in_array($key, $this->htmlAllowedAttributes)) {
        $this->assertEqual(strip_tags($item), $item, 'JSON Feed item: \'' . $key . '\' does not contain HTML.');
        $this->assertEquals(strip_tags($item), $item, 'JSON Feed item: \'' . $key . '\' does not contain HTML.');
      }
    });
  }
@@ -182,7 +180,7 @@ class DisplayJsonFeedTest extends ViewTestBase {
    else {
      $this->assertFalse(array_key_exists('next_url', $feed_content), 'JSON Feed next_url attribute not present.');
    }
    $this->assertEqual($this->expectedFirstPageItems(), count($feed_content['items']), 'JSON Feed first page returned ' . $this->expectedFirstPageItems() . ' items.');
    $this->assertEquals($this->expectedFirstPageItems(), count($feed_content['items']), 'JSON Feed first page returned ' . $this->expectedFirstPageItems() . ' items.');
  }

  /**
@@ -193,7 +191,7 @@ class DisplayJsonFeedTest extends ViewTestBase {

    $this->assertFalse(array_key_exists('next_url', $feed_content), 'JSON Feed next_url attribute not present on last page.');
    $expectedLastPageItemsCount = $this->nodesToCreate % $this->feedItemsPerPage;
    $this->assertEqual($expectedLastPageItemsCount, count($feed_content['items']), 'JSON Feed last page returned ' . $expectedLastPageItemsCount . ' items.');
    $this->assertEquals($expectedLastPageItemsCount, count($feed_content['items']), 'JSON Feed last page returned ' . $expectedLastPageItemsCount . ' items.');
  }

  /**