You are here

public function UniqueFieldConstraintTest::providerTestEntityWithStringIdWithViolation in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/KernelTests/Core/Validation/UniqueFieldConstraintTest.php \Drupal\KernelTests\Core\Validation\UniqueFieldConstraintTest::providerTestEntityWithStringIdWithViolation()
  2. 9 core/tests/Drupal/KernelTests/Core/Validation/UniqueFieldConstraintTest.php \Drupal\KernelTests\Core\Validation\UniqueFieldConstraintTest::providerTestEntityWithStringIdWithViolation()

Data provider for ::testEntityWithStringIdWithViolation().

Return value

array An array of test cases.

See also

self::testEntityWithStringIdWithViolation()

File

core/tests/Drupal/KernelTests/Core/Validation/UniqueFieldConstraintTest.php, line 104

Class

UniqueFieldConstraintTest
Tests the unique field value validation constraint.

Namespace

Drupal\KernelTests\Core\Validation

Code

public function providerTestEntityWithStringIdWithViolation() {
  return [
    'without an id' => [
      NULL,
    ],
    'zero as integer' => [
      0,
    ],
    'zero as string' => [
      "0",
    ],
    'non-zero as integer' => [
      mt_rand(1, 127),
    ],
    'non-zero as string' => [
      (string) mt_rand(1, 127),
    ],
    'alphanumeric' => [
      $this
        ->randomMachineName(),
    ],
  ];
}