You are here

protected function ParserCSVTest::_testEncodingConversion in Feeds 7.2

Simple test of encoding conversion prior to parsing.

1 call to ParserCSVTest::_testEncodingConversion()
ParserCSVTest::test in tests/parser_csv.test
Test method.

File

tests/parser_csv.test, line 64
Tests for ParserCSV library.

Class

ParserCSVTest
Test aggregating a feed as node items.

Code

protected function _testEncodingConversion() {

  // Pull in the $control_result array.
  include $this
    ->absolutePath() . '/tests/feeds/encoding.csv.php';
  $encodings = $this
    ->getEncodings();
  foreach ($encodings as $encoding) {
    $file = $this
      ->absolutePath() . "/tests/feeds/encoding_{$encoding}.csv";
    $iterator = new ParserCSVIterator($file);
    $parser = new ParserCSV();
    $parser
      ->setDelimiter(',');
    $parser
      ->setEncoding($encoding);
    $rows = $parser
      ->parse($iterator);
    $this
      ->assertFalse($parser
      ->lastLinePos(), format_string('CSV reports all lines parsed, with encoding: %encoding', array(
      '%encoding' => $encoding,
    )));
    $this
      ->assertEqual(md5(serialize($rows)), md5(serialize($control_result)), 'Converted and parsed result matches control result.');
  }
}