You are here

public function FeedsExJmesPathUnitTests::testEUCJPEncoded in Feeds extensible parsers 7.2

Tests a EUC-JP (Japanese) encoded file.

This implicitly tests FeedsExBase's encoding conversion.

File

src/Tests/FeedsExJmesPath.test, line 71
Contains tests for FeedsExJmesPath.

Class

FeedsExJmesPathUnitTests
Unit tests for FeedsExJmesPath.

Code

public function testEUCJPEncoded() {
  $parser = FeedsConfigurable::instance('FeedsExJmesPath', 'test_parser');
  $fetcher_result = new FeedsFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test_jp.json'));
  $parser
    ->setConfig(array(
    'context' => array(
      'value' => 'items',
    ),
    'sources' => array(
      'title' => array(
        'name' => 'Title',
        'value' => 'title',
      ),
      'description' => array(
        'name' => 'Title',
        'value' => 'description',
      ),
    ),
    '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']);
  }
}