class ConcatTest

Same name and namespace in other branches
  1. 11.x core/modules/migrate/tests/src/Unit/process/ConcatTest.php \Drupal\Tests\migrate\Unit\process\ConcatTest
  2. 10 core/modules/migrate/tests/src/Unit/process/ConcatTest.php \Drupal\Tests\migrate\Unit\process\ConcatTest
  3. 8.9.x core/modules/migrate/tests/src/Unit/process/ConcatTest.php \Drupal\Tests\migrate\Unit\process\ConcatTest

Tests the concat process plugin.

@group migrate

Hierarchy

Expanded class hierarchy of ConcatTest

File

core/modules/migrate/tests/src/Unit/process/ConcatTest.php, line 18

Namespace

Drupal\Tests\migrate\Unit\process
View source
class ConcatTest extends MigrateProcessTestCase {
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    $this->plugin = new TestConcat();
    parent::setUp();
  }
  
  /**
   * Tests concat works without a delimiter.
   */
  public function testConcatWithoutDelimiter() {
    $value = $this->plugin
      ->transform([
      'foo',
      'bar',
    ], $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame('foobar', $value);
  }
  
  /**
   * Tests concat fails properly on non-arrays.
   */
  public function testConcatWithNonArray() {
    $this->expectException(MigrateException::class);
    $this->plugin
      ->transform('foo', $this->migrateExecutable, $this->row, 'destination_property');
  }
  
  /**
   * Tests concat works without a delimiter.
   */
  public function testConcatWithDelimiter() {
    $this->plugin
      ->setDelimiter('_');
    $value = $this->plugin
      ->transform([
      'foo',
      'bar',
    ], $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame('foo_bar', $value);
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.