You are here

public function FeedsExHtmlUnitTests::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/FeedsExHtml.test, line 110
Contains tests for FeedsExHtml.

Class

FeedsExHtmlUnitTests
Unit tests for FeedsExHtml.

Code

public function testEUCJPEncodedNoDeclaration() {
  $parser = FeedsConfigurable::instance('FeedsExHtml', 'test_parser');
  $fetcher_result = new FeedsFetcherResult(file_get_contents($this->moduleDir . '/tests/resources/test_jp.html'));
  $parser
    ->setConfig(array(
    'context' => array(
      'value' => '//div[@class="post"]',
    ),
    'sources' => array(
      'title' => array(
        'name' => 'Title',
        'value' => 'h3',
      ),
      'description' => array(
        'name' => 'Title',
        'value' => 'p',
      ),
    ),
    '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']);
  }
}