You are here

protected function CSVExportViewsDataExportTests::testIconvEncoding in Views data export 7.4

Same name and namespace in other branches
  1. 7.3 tests/csv_export.test \CSVExportViewsDataExportTests::testIconvEncoding()

Test to ensure that Encoding options work.

File

tests/csv_export.test, line 184

Class

CSVExportViewsDataExportTests

Code

protected function testIconvEncoding() {
  $view = $this
    ->getBasicExportView();
  db_update('views_test')
    ->fields(array(
    'name' => 'Jo€hn',
  ))
    ->condition('name', 'John')
    ->execute();
  $encodings = array(
    'ISO-8859-1//TRANSLIT' => 'EUR',
    'utf8_decode' => '?',
  );
  foreach ($encodings as $encoding => $conversion) {
    $style_options = array(
      'exporter_options' => array(
        'encoding' => $encoding,
      ),
    );
    $expected = '"ID","Name","Age"
"1","Jo' . $conversion . 'hn","25"
"2","George","27"
"3","Ringo","28"
"4","Paul","26"
"5","Meredith","30"';
    $message = 'Character encoding ' . $encoding . ' worked correctly.';
    $this
      ->executeAndCompareGivenView($view, $expected, $message, $style_options);
  }
}