You are here

public function QueryPathXmlParserTest::testMultipleAttributeParsing in Feeds extensible parsers 8

Tests grabbing multiple attributes.

File

tests/src/Unit/Feeds/Parser/QueryPathXmlParserTest.php, line 172

Class

QueryPathXmlParserTest
@coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\QueryPathXmlParser @group feeds_ex

Namespace

Drupal\Tests\feeds_ex\Unit\Feeds\Parser

Code

public function testMultipleAttributeParsing() {
  $fetcher_result = new RawFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test.xml'), $this->fileSystem);
  $config = [
    'context' => [
      'value' => 'items thing',
    ],
    'sources' => [
      'url' => [
        'name' => 'URL',
        'value' => 'img',
        'attribute' => 'src',
      ],
    ],
  ];
  $this->parser
    ->setConfiguration($config);
  $result = $this->parser
    ->parse($this->feed, $fetcher_result, $this->state);
  $this
    ->assertCount(1, $result);
  $url = $result[0]
    ->get('url');
  $this
    ->assertCount(2, $url);
  $this
    ->assertSame($url[0], 'http://drupal.org');
  $this
    ->assertSame($url[1], 'http://drupal.org/project/feeds_ex');
}