You are here

public function StrReplaceTest::testPregReplace in Migrate Plus 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Unit/process/StrReplaceTest.php \Drupal\Tests\migrate_plus\Unit\process\StrReplaceTest::testPregReplace()

Test for regular expressions.

File

tests/src/Unit/process/StrReplaceTest.php, line 46

Class

StrReplaceTest
Tests the str replace process plugin.

Namespace

Drupal\Tests\migrate_plus\Unit\process

Code

public function testPregReplace() {
  $value = 'vero eos et 123 accusam et justo 123 duo';
  $configuration['search'] = '/[0-9]{3}/';
  $configuration['replace'] = 'the';
  $configuration['regex'] = TRUE;
  $plugin = new StrReplace($configuration, 'str_replace', []);
  $actual = $plugin
    ->transform($value, $this->migrateExecutable, $this->row, 'destinationproperty');
  $this
    ->assertSame('vero eos et the accusam et justo the duo', $actual);
}