abstract class CSVUnitBase in Migrate Source CSV 8.2
Base class for CSV unit tests.
@group migrate_source_csv
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\migrate_source_csv\Unit\CSVUnitBase
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\UnitView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CSVUnitBase:: |
protected | property | The happy path file url. | |
CSVUnitBase:: |
protected | property | The multi line file url. | |
CSVUnitBase:: |
protected | property | The un-happy path file url. | |
CSVUnitBase:: |
protected | function |
Overrides UnitTestCase:: |
3 |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |