You are here

public function JmesPathParserTest::testSimpleParsing in Feeds extensible parsers 8

Tests simple parsing.

File

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

Class

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

Namespace

Drupal\Tests\feeds_ex\Unit\Feeds\Parser

Code

public function testSimpleParsing() {
  $fetcher_result = new RawFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test.json'), $this->fileSystem);
  $config = [
    'context' => [
      'value' => 'items',
    ],
    'sources' => [
      'title' => [
        'name' => 'Title',
        'value' => 'title',
      ],
      'description' => [
        'name' => 'Title',
        'value' => 'description',
      ],
    ],
  ];
  $this->parser
    ->setConfiguration($config);
  $result = $this->parser
    ->parse($this->feed, $fetcher_result, $this->state);
  $this
    ->assertCount(3, $result);
  foreach ($result as $delta => $item) {
    $this
      ->assertSame('I am a title' . $delta, $item
      ->get('title'));
    $this
      ->assertSame('I am a description' . $delta, $item
      ->get('description'));
  }
}