You are here

public function FindReplaceRegexTest::testSingleValueWhiteSpace in Tamper 8

Test the plugin with whitespace.

File

tests/src/Unit/Plugin/Tamper/FindReplaceRegexTest.php, line 86

Class

FindReplaceRegexTest
Tests the find and replace regex plugin.

Namespace

Drupal\Tests\tamper\Unit\Plugin\Tamper

Code

public function testSingleValueWhiteSpace() {
  $config = [
    FindReplaceRegex::SETTING_FIND => '/cat\\s/',
    FindReplaceRegex::SETTING_REPLACE => 'dog',
    FindReplaceRegex::SETTING_LIMIT => '',
  ];
  $plugin = new FindReplaceRegex($config, 'find_replace_regex', [], $this
    ->getMockSourceDefinition());
  $this
    ->assertEquals('The dog went to the park.', $plugin
    ->tamper("The cat\n went to the park."));
  $config = [
    FindReplaceRegex::SETTING_FIND => '/cat\\t/',
    FindReplaceRegex::SETTING_REPLACE => 'dog',
    FindReplaceRegex::SETTING_LIMIT => '',
  ];
  $plugin = new FindReplaceRegex($config, 'find_replace_regex', [], $this
    ->getMockSourceDefinition());
  $this
    ->assertEquals('The dog went to the park.', $plugin
    ->tamper("The cat\t went to the park."));
}