You are here

protected function SourceCsvFormTest::setUp in Migrate Tools 8.4

Overrides BrowserTestBase::setUp

File

tests/src/Functional/SourceCsvFormTest.php, line 63

Class

SourceCsvFormTest
Test the CSV column alias edit form.

Namespace

Drupal\Tests\migrate_tools\Functional

Code

protected function setUp() {
  parent::setUp();

  // Log in as user 1. Migrations in the UI can only be performed as user 1.
  $this
    ->drupalLogin($this->rootUser);

  // Setup the file system so we create the source CSV.
  $this->container
    ->get('stream_wrapper_manager')
    ->registerWrapper('public', PublicStream::class, StreamWrapperInterface::NORMAL);
  $fs = \Drupal::service('file_system');
  $fs
    ->mkdir('public://sites/default/files', NULL, TRUE);

  // The source data for this test.
  $source_data = <<<'EOD'
vid,name,description,hierarchy,weight
tags,Tags,Use tags to group articles,0,0
forums,Sujet de discussion,Forum navigation vocabulary,1,0
test_vocabulary,Test Vocabulary,This is the vocabulary description,1,0
genre,Genre,Genre description,1,0
EOD;

  // Write the data to the filepath given in the test migration.
  file_put_contents('public://test.csv', $source_data);

  // Get the store.
  $tempStoreFactory = \Drupal::service('tempstore.private');
  $this->store = $tempStoreFactory
    ->get('migrate_tools');

  // Select the group and migration to test.
  $this->group = 'csv_test';
  $this->migration = 'csv_source_test';
}