function ExplodeTest::testExplodeWithNonStrictAndNonCastable

Same name in other branches
  1. 8.9.x core/modules/migrate/tests/src/Unit/process/ExplodeTest.php \Drupal\Tests\migrate\Unit\process\ExplodeTest::testExplodeWithNonStrictAndNonCastable()
  2. 10 core/modules/migrate/tests/src/Unit/process/ExplodeTest.php \Drupal\Tests\migrate\Unit\process\ExplodeTest::testExplodeWithNonStrictAndNonCastable()
  3. 11.x core/modules/migrate/tests/src/Unit/process/ExplodeTest.php \Drupal\Tests\migrate\Unit\process\ExplodeTest::testExplodeWithNonStrictAndNonCastable()

Tests Explode exception handling when string-cast fails.

File

core/modules/migrate/tests/src/Unit/process/ExplodeTest.php, line 94

Class

ExplodeTest
Tests the Explode process plugin.

Namespace

Drupal\Tests\migrate\Unit\process

Code

public function testExplodeWithNonStrictAndNonCastable() {
    $plugin = new Explode([
        'delimiter' => '|',
        'strict' => FALSE,
    ], 'map', []);
    $this->expectException(MigrateException::class);
    $this->expectExceptionMessage('cannot be casted to a string');
    $processed = $plugin->transform([
        'foo',
    ], $this->migrateExecutable, $this->row, 'destination_property');
    $this->assertSame([
        'foo',
    ], $processed);
}

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