You are here

abstract class CSVUnitBase in Migrate Source CSV 8.2

Base class for CSV unit tests.

@group migrate_source_csv

Hierarchy

Expanded class hierarchy of CSVUnitBase

2 files declare their use of CSVUnitBase
CSVSourceYieldTest.php in tests/src/Unit/Plugin/migrate/source/CSVSourceYieldTest.php
CSVUnitTest.php in tests/src/Unit/Plugin/migrate/source/CSVUnitTest.php

File

tests/src/Unit/CSVUnitBase.php, line 13

Namespace

Drupal\Tests\migrate_source_csv\Unit
View source
abstract class CSVUnitBase extends UnitTestCase {

  /**
   * The happy path file url.
   *
   * @var string
   */
  protected $happyPath;

  /**
   * The un-happy path file url.
   *
   * @var string
   */
  protected $sad;

  /**
   * The multi line file url.
   *
   * @var string
   */
  protected $multiLine;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $root_dir = vfsStream::setup('root');
    $happy = <<<'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
3,William,Ray,wray2@example.com,Germany,4.75.251.71
4,Jack,Collins,jcollins3@example.com,Indonesia,118.241.243.64
5,Jean,Moreno,jmoreno4@example.com,Portugal,12.24.215.20
6,Dennis,Mitchell,dmitchell5@example.com,Mexico,185.24.131.116
7,Harry,West,hwest6@example.com,Uzbekistan,101.74.110.171
8,Rebecca,Hunt,rhunt7@example.com,France,253.107.6.23
9,Rose,Rogers,rrogers8@example.com,China,21.2.126.228
10,Juan,Walker,jwalker9@example.com,Angola,192.118.77.225
11,Lois,Price,lpricea@example.com,Greece,231.185.100.19
12,Patricia,Bell,pbellb@example.com,Sweden,226.2.254.94
13,Gerald,Kelly,gkellyc@example.com,China,31.204.2.163
14,Kimberly,Jackson,kjacksond@example.com,Thailand,19.187.65.116
15,Jason,Mason,jmasone@example.com,Greece,225.129.68.203
EOD;
    $sad = <<<'EOD'
1|%Justin%|Dean|jdean0@example.com|Indonesia|60.242.130.40
2|Joan|Jordan|jjordan1@example.com|Thailand|137.230.209.171
3|William|Ray|wray2@example.com|Germany|4.75.251.71
4|Jack|Collins|jcollins3@example.com|Indonesia|118.241.243.64
5|Jean|Moreno|jmoreno4@example.com|Portugal|12.24.215.20
6|Dennis|Mitchell|dmitchell5@example.com|Mexico|185.24.131.116
7|Harry|West|hwest6@example.com|Uzbekistan|101.74.110.171
8|Rebecca|Hunt|rhunt7@example.com|France|253.107.6.23
9|Rose|Rogers|rrogers8@example.com|China|21.2.126.228
10|Juan|Walker|jwalker9@example.com|Angola|192.118.77.225
11|Lois|Price|lpricea@example.com|Greece|231.185.100.19
12|Patricia|Bell|pbellb@example.com|Sweden|226.2.254.94
13|Gerald|Kelly|gkellyc@example.com|China|31.204.2.163
14|Kimberly|Jackson|kjacksond@example.com|Thailand|19.187.65.116
15|Jason|Mason|jmasone@example.com|Greece|225.129.68.203

EOD;
    $multiLineContent = <<<'EOD'
id,title,description
1,"Title 1","Description 1 Line 1
Description 1 Line 2
Description 1 Line 3"
2,"Title 2","Description 2 Line 1
Description 2 Line 2
Description 2 Line 3"
3,"Title 3","Description 3 Line 1
Description 3 Line 2
Description 3 Line 3"
EOD;
    $this->happyPath = vfsStream::newFile('data.csv')
      ->at($root_dir)
      ->withContent($happy)
      ->url();
    $this->sad = vfsStream::newFile('data_edge_case.csv')
      ->at($root_dir)
      ->withContent($sad)
      ->url();
    $this->multiLine = vfsStream::newFile('multi-line.csv')
      ->at($root_dir)
      ->withContent($multiLineContent)
      ->url();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CSVUnitBase::$happyPath protected property The happy path file url.
CSVUnitBase::$multiLine protected property The multi line file url.
CSVUnitBase::$sad protected property The un-happy path file url.
CSVUnitBase::setUp protected function Overrides UnitTestCase::setUp 3
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.