5 * Contains \Drupal\Tests\migrate\Unit\process\ConcatTest.
8 namespace Drupal\Tests\migrate\Unit\process;
10 use Drupal\migrate\MigrateException;
11 use Drupal\migrate\Plugin\migrate\process\Concat;
14 * Tests the concat process plugin.
18 class ConcatTest extends MigrateProcessTestCase {
23 protected function setUp() {
24 $this->plugin = new TestConcat();
29 * Test concat works without a delimiter.
31 public function testConcatWithoutDelimiter() {
32 $value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
33 $this->assertSame($value, 'foobar');
37 * Test concat fails properly on non-arrays.
39 public function testConcatWithNonArray() {
40 $this->setExpectedException(MigrateException::class);
41 $this->plugin->transform('foo', $this->migrateExecutable, $this->row, 'destinationproperty');
45 * Test concat works without a delimiter.
47 public function testConcatWithDelimiter() {
48 $this->plugin->setDelimiter('_');
49 $value = $this->plugin->transform(['foo', 'bar'], $this->migrateExecutable, $this->row, 'destinationproperty');
50 $this->assertSame($value, 'foo_bar');
55 class TestConcat extends Concat {
56 public function __construct() {
62 * @param string $delimiter
65 public function setDelimiter($delimiter) {
66 $this->configuration['delimiter'] = $delimiter;