CSVTest.php in Migrate Source CSV 8.3
File
tests/src/Kernel/Plugin/migrate/source/CSVTest.php
View source
<?php
namespace Drupal\Tests\migrate_source_csv\Kernel\Plugin\migrate\source;
use Drupal\node\Entity\Node;
use Drupal\Tests\migrate\Kernel\MigrateTestBase;
class CSVTest extends MigrateTestBase {
public static $modules = [
'system',
'field',
'user',
'node',
'datetime',
'migrate',
'migrate_source_csv',
'migrate_source_csv_test',
];
public function testMigrate() : void {
$this
->installEntitySchema('user');
$this
->installEntitySchema('node');
$this
->installConfig([
'migrate_source_csv_test',
]);
$migrationManager = $this->container
->get('plugin.manager.migration');
$migration = $migrationManager
->createInstance('migrate_csv_test');
$this
->executeMigration($migration);
$node = Node::load(1);
$this
->assertEquals($node
->label(), 'Justin Dean');
$this
->assertEquals($node
->get('field_first_name')->value, 'Justin');
$this
->assertEquals($node
->get('field_last_name')->value, 'Dean');
$this
->assertEquals($node
->get('field_email')->value, 'jdean0@example.com');
$this
->assertEquals($node
->get('field_ip_address')->value, '60.242.130.40');
$this
->assertEquals($node
->get('field_dob')->value, '1955-01-05');
}
}