You are here

public function HtmlParserTest::testCp866Encoded in Feeds extensible parsers 8

Tests parsing a CP866 (Russian) encoded file.

File

tests/src/Unit/Feeds/Parser/HtmlParserTest.php, line 138

Class

HtmlParserTest
@coversDefaultClass \Drupal\feeds_ex\Feeds\Parser\HtmlParser @group feeds_ex

Namespace

Drupal\Tests\feeds_ex\Unit\Feeds\Parser

Code

public function testCp866Encoded() {
  $fetcher_result = new RawFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test_ru.html'), $this->fileSystem);
  $config = [
    'context' => [
      'value' => '//div[@class="post"]',
    ],
    'sources' => [
      'title' => [
        'name' => 'Title',
        'value' => 'h3',
      ],
      'description' => [
        'name' => 'Title',
        'value' => 'p',
      ],
    ],
  ] + $this->parser
    ->defaultConfiguration();
  $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('Я название' . $delta, $item
      ->get('title'));
    $this
      ->assertSame('Я описание' . $delta, $item
      ->get('description'));
  }
}