ConcatTest.php in Drupal 10
File
core/modules/migrate/tests/src/Unit/process/ConcatTest.php
View source
<?php
namespace Drupal\Tests\migrate\Unit\process;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\migrate\process\Concat;
class ConcatTest extends MigrateProcessTestCase {
protected function setUp() : void {
$this->plugin = new TestConcat();
parent::setUp();
}
public function testConcatWithoutDelimiter() {
$value = $this->plugin
->transform([
'foo',
'bar',
], $this->migrateExecutable, $this->row, 'destination_property');
$this
->assertSame('foobar', $value);
}
public function testConcatWithNonArray() {
$this
->expectException(MigrateException::class);
$this->plugin
->transform('foo', $this->migrateExecutable, $this->row, 'destination_property');
}
public function testConcatWithDelimiter() {
$this->plugin
->setDelimiter('_');
$value = $this->plugin
->transform([
'foo',
'bar',
], $this->migrateExecutable, $this->row, 'destination_property');
$this
->assertSame('foo_bar', $value);
}
}
class TestConcat extends Concat {
public function __construct() {
}
public function setDelimiter($delimiter) {
$this->configuration['delimiter'] = $delimiter;
}
}