You are here

public function CsvEncoderTest::provideDecodeData in CSV Serialization 8

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/CsvEncoderTest.php \Drupal\Tests\csv_serialization\Unit\CsvEncoderTest::provideDecodeData()

Provides data for testing the decoder.

File

tests/src/Unit/CsvEncoderTest.php, line 80

Class

CsvEncoderTest
Tests the encoding and decoding functionality of CsvEncoder.

Namespace

Drupal\Tests\csv_serialization\Unit

Code

public function provideDecodeData() {
  $csv1_encoded = file_get_contents(__DIR__ . '/CsvEncoderTest.csv');
  $csv1_data = [
    // Row 1.
    [
      'title' => 'This is title 1',
      'body' => 'This is, body 1',
      'images' => 'img1.jpg',
      'alias' => '',
      'status' => 1,
    ],
    // Row 2.
    [
      'title' => 'This is title 2',
      'body' => 'This is, body 2',
      'images' => [
        'img1.jpg',
        'img2.jpg',
      ],
      'alias' => '',
      'status' => 0,
    ],
    // Row 3.
    [
      'title' => 'This is title 3',
      'body' => 'This is, body 3',
      // Note that due to the flattening of multi-dimensional arrays
      // during encoding, this does not match Row 3 in provideEncodeData().
      'images' => [
        'img1.jpg',
        'Image 1',
        'img2.jpg',
        'Image, 2',
      ],
      'alias' => '',
      'status' => 0,
    ],
  ];
  return [
    [
      $csv1_encoded,
      $csv1_data,
    ],
  ];
}