You are here

public function DisplayJsonFeedTest::testHtmlPresence in JSON Feed 8

Test fields that should not include HTML.

File

tests/src/Functional/DisplayJsonFeedTest.php, line 165

Class

DisplayJsonFeedTest
Tests the json_feed display plugin.

Namespace

Drupal\Tests\json_feed\Functional

Code

public function testHtmlPresence() {
  $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.');
    }
  });
}