You are here

public function FeedsExQueryPathXmlUnitTests::testEUCJPEncodedNoDeclaration in Feeds extensible parsers 7.2

Tests a EUC-JP (Japanese) encoded file without the encoding declaration.

This implicitly tests FeedsExBase's encoding conversion.

File

src/Tests/FeedsExQueryPathXml.test, line 151
Contains tests for FeedsExQueryPathXml.

Class

FeedsExQueryPathXmlUnitTests
Unit tests for FeedsExQueryPathXml.

Code

public function testEUCJPEncodedNoDeclaration() {
  $parser = FeedsConfigurable::instance('FeedsExQueryPathXml', 'test_parser');
  $fetcher_result = new FeedsFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test_jp.xml'));
  $parser
    ->setConfig(array(
    'context' => array(
      'value' => 'items item',
    ),
    'sources' => array(
      'title' => array(
        'name' => 'Title',
        'value' => 'title',
        'attribute' => '',
      ),
      'description' => array(
        'name' => 'Title',
        'value' => 'description',
        'attribute' => '',
      ),
    ),
    'source_encoding' => array(
      'EUC-JP',
    ),
  ));
  $result = $parser
    ->parse($this->source, $fetcher_result);
  $this
    ->assertEqual(count($result->items), 3, format_string('@count items parsed.', array(
    '@count' => count($result->items),
  )));
  foreach ($result->items as $delta => $item) {
    $this
      ->assertEqual('私はタイトルです' . $delta, $item['title']);
    $this
      ->assertEqual('私が説明してい' . $delta, $item['description']);
  }
}