class ArrayBuildTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/migrate/tests/src/Unit/process/ArrayBuildTest.php \Drupal\Tests\migrate\Unit\process\ArrayBuildTest
- 9 core/modules/migrate/tests/src/Unit/process/ArrayBuildTest.php \Drupal\Tests\migrate\Unit\process\ArrayBuildTest
@coversDefaultClass \Drupal\migrate\Plugin\migrate\process\ArrayBuild @group migrate
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitWarnings
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase
- class \Drupal\Tests\migrate\Unit\process\ArrayBuildTest
- class \Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
Expanded class hierarchy of ArrayBuildTest
File
- core/
modules/ migrate/ tests/ src/ Unit/ process/ ArrayBuildTest.php, line 12
Namespace
Drupal\Tests\migrate\Unit\processView source
class ArrayBuildTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() : void {
$configuration = [
'key' => 'foo',
'value' => 'bar',
];
$this->plugin = new ArrayBuild($configuration, 'map', []);
parent::setUp();
}
/**
* Tests successful transformation.
*/
public function testTransform() {
$source = [
[
'foo' => 'Foo',
'bar' => 'Bar',
],
[
'foo' => 'foo bar',
'bar' => 'bar foo',
],
];
$expected = [
'Foo' => 'Bar',
'foo bar' => 'bar foo',
];
$value = $this->plugin
->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
$this
->assertSame($value, $expected);
}
/**
* Tests non-existent key for the key configuration.
*/
public function testNonExistentKey() {
$source = [
[
'bar' => 'foo',
],
];
$this
->expectException(MigrateException::class);
$this
->expectExceptionMessage("The key 'foo' does not exist");
$this->plugin
->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
}
/**
* Tests non-existent key for the value configuration.
*/
public function testNonExistentValue() {
$source = [
[
'foo' => 'bar',
],
];
$this
->expectException(MigrateException::class);
$this
->expectExceptionMessage("The key 'bar' does not exist");
$this->plugin
->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
}
/**
* Tests one-dimensional array input.
*/
public function testOneDimensionalArrayInput() {
$source = [
'foo' => 'bar',
];
$this
->expectException(MigrateException::class);
$this
->expectExceptionMessage('The input should be an array of arrays');
$this->plugin
->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
}
/**
* Tests string input.
*/
public function testStringInput() {
$source = 'foo';
$this
->expectException(MigrateException::class);
$this
->expectExceptionMessage('The input should be an array of arrays');
$this->plugin
->transform($source, $this->migrateExecutable, $this->row, 'destination_property');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ArrayBuildTest:: |
protected | function |
Overrides MigrateProcessTestCase:: |
|
ArrayBuildTest:: |
public | function | Tests non-existent key for the key configuration. | |
ArrayBuildTest:: |
public | function | Tests non-existent key for the value configuration. | |
ArrayBuildTest:: |
public | function | Tests one-dimensional array input. | |
ArrayBuildTest:: |
public | function | Tests string input. | |
ArrayBuildTest:: |
public | function | Tests successful transformation. | |
MigrateProcessTestCase:: |
protected | property | ||
MigrateProcessTestCase:: |
protected | property | ||
MigrateProcessTestCase:: |
protected | property | ||
MigrateTestCase:: |
protected | property | The migration ID map. | |
MigrateTestCase:: |
protected | property | An array of migration configuration values. | 5 |
MigrateTestCase:: |
protected | property | Local store for mocking setStatus()/getStatus(). | |
MigrateTestCase:: |
protected | function | Generates a table schema from a row. | |
MigrateTestCase:: |
protected | function | Gets an SQLite database connection object for use in tests. | |
MigrateTestCase:: |
protected | function | Retrieves a mocked migration. | |
MigrateTestCase:: |
protected | function | Gets the value on a row for a given key. | |
MigrateTestCase:: |
public | function | Tests a query. | |
MigrateTestCase:: |
protected | function | Asserts tested values during test retrieval. | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 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. | |
UnitTestCase:: |
public static | function |