You are here

public function MachineNameControllerTest::testMachineNameControllerWithInvalidReplacePattern in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php \Drupal\Tests\system\Unit\Transliteration\MachineNameControllerTest::testMachineNameControllerWithInvalidReplacePattern()
  2. 9 core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php \Drupal\Tests\system\Unit\Transliteration\MachineNameControllerTest::testMachineNameControllerWithInvalidReplacePattern()

Tests the pattern validation.

File

core/modules/system/tests/src/Unit/Transliteration/MachineNameControllerTest.php, line 106

Class

MachineNameControllerTest
Tests that the machine name controller can transliterate strings as expected.

Namespace

Drupal\Tests\system\Unit\Transliteration

Code

public function testMachineNameControllerWithInvalidReplacePattern() {
  $request = Request::create('', 'GET', [
    'text' => 'Bob',
    'langcode' => 'en',
    'replace' => 'Alice',
    'replace_pattern' => 'Bob',
    'replace_token' => 'invalid',
  ]);
  $this
    ->expectException(AccessDeniedHttpException::class);
  $this
    ->expectExceptionMessage("Invalid 'replace_token' query parameter.");
  $this->machineNameController
    ->transliterate($request);
}