You are here

public function FindReplaceTest::testSingleValueWhole in Tamper 8

Test the plugin as replace whole words only.

File

tests/src/Unit/Plugin/Tamper/FindReplaceTest.php, line 84

Class

FindReplaceTest
Tests the find and replace plugin.

Namespace

Drupal\Tests\tamper\Unit\Plugin\Tamper

Code

public function testSingleValueWhole() {
  $config = [
    FindReplace::SETTING_FIND => 'cat',
    FindReplace::SETTING_REPLACE => 'dog',
    FindReplace::SETTING_CASE_SENSITIVE => FALSE,
    FindReplace::SETTING_WORD_BOUNDARIES => FALSE,
    FindReplace::SETTING_WHOLE => TRUE,
  ];
  $plugin = new FindReplace($config, 'find_replace', [], $this
    ->getMockSourceDefinition());
  $this
    ->assertEquals('The cat went to the park.', $plugin
    ->tamper('The cat went to the park.'));
  $this
    ->assertEquals('dog', $plugin
    ->tamper('cat'));
  $this
    ->assertEquals('dog', $plugin
    ->tamper('Cat'));
}