You are here

public function JmesPathParserTest::testRootContext in Feeds extensible parsers 8

Tests parsing with a root object.

File

tests/src/Unit/Feeds/Parser/JmesPathParserTest.php, line 148

Class

JmesPathParserTest
@coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\JmesPathParser @group feeds_ex

Namespace

Drupal\Tests\feeds_ex\Unit\Feeds\Parser

Code

public function testRootContext() {
  $fetcher_result = new RawFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test.json'), $this->fileSystem);
  $config = [
    'context' => [
      'value' => '@',
    ],
    'sources' => [
      'title' => [
        'name' => 'Title',
        'value' => 'items[0].title',
      ],
    ],
  ];
  $this->parser
    ->setConfiguration($config);
  $result = $this->parser
    ->parse($this->feed, $fetcher_result, $this->state);
  $this
    ->assertCount(1, $result);
  $this
    ->assertEquals('I am a title0', $result[0]
    ->get('title'));
}