You are here

protected function CSVUnitTest::setUp in Migrate Source CSV 8.3

Same name and namespace in other branches
  1. 8.2 tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php \Drupal\Tests\migrate_source_csv\Unit\Plugin\migrate\source\CSVUnitTest::setUp()

Overrides UnitTestCase::setUp

File

tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php, line 55

Class

CSVUnitTest
@coversDefaultClass \Drupal\migrate_source_csv\Plugin\migrate\source\CSV

Namespace

Drupal\Tests\migrate_source_csv\Unit\Plugin\migrate\source

Code

protected function setUp() : void {
  parent::setUp();
  $this->pluginId = 'test csv migration';
  $this->pluginDefinition = [];
  $migration = $this
    ->prophesize(MigrationInterface::class);
  $migration
    ->getIdMap()
    ->willReturn(NULL);
  $this->migration = $migration
    ->reveal();
  $standard_chars = <<<'EOD'
id,first_name,last_name,email,country,ip_address
1,Justin,Dean,jdean0@example.com,Indonesia,60.242.130.40
2,Joan,Jordan,jjordan1@example.com,Thailand,137.230.209.171
EOD;
  $non_standard_chars = <<<'EOD'
1|%Justin%|Dean|jdean0@example.com|Indonesia|60.242.130.40
2|Joan|Jordan|jjordan1@example.com|Thailand|137.230.209.171

EOD;
  $root_dir = vfsStream::setup('root');
  $this->standardCharsPath = vfsStream::newFile('data.csv')
    ->at($root_dir)
    ->withContent($standard_chars)
    ->url();
  $this->nonStandardCharsPath = vfsStream::newFile('data_edge_case.csv')
    ->at($root_dir)
    ->withContent($non_standard_chars)
    ->url();
}