Commit 4b8cd47d authored by benjifisher's avatar benjifisher Committed by Lucas Hedding
Browse files

244: Add a unit test

parent b7f85d84
<?php
namespace Drupal\Tests\migrate_plus\Unit\process;
use Drupal\migrate_plus\Plugin\migrate\process\Transpose;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
/**
* Tests the transpose process plugin.
*
* @group migrate
* @coversDefaultClass \Drupal\migrate_plus\Plugin\migrate\process\Transpose
*/
class TransposeTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
protected function setUp(): void {
$this->plugin = new Transpose([], 'array_pop', []);
parent::setUp();
}
/**
* Test transpose plugin.
*
* @param array $input
* The input values.
* @param mixed $expected_output
* The expected output.
*
* @dataProvider transposeDataProvider
*/
public function testTranspose(array $input, $expected_output): void {
$output = $this->plugin->transform($input, $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame($output, $expected_output);
}
/**
* Data provider for testTranspose().
*
* @return array
* An array containing input values and expected output values.
*/
public function transposeDataProvider(): array {
return [
'empty array' => [
'input' => [],
'expected_output' => [],
],
'image files and alt text' => [
'input' => [['2.png', '3.png', '5.png', '7.png'], ['two', 'three', 'five', 'seven']],
'expected_output' => [['2.png', 'two'], ['3.png', 'three'], ['5.png', 'five'], ['7.png', 'seven']],
],
'indexed arrays' => [
'input' => [['a' => 1, 'b' => 2], ['c' => 3, 'd' => 4], ['e' => 5, 'f' => 6], ['g' => 7, 'h' => 8]],
'output' => [[1, 3, 5, 7], [2, 4, 6, 8]],
],
];
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment