function UniqueFieldConstraintTest::providerTestEntityWithStringIdWithViolation

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Validation/UniqueFieldConstraintTest.php \Drupal\KernelTests\Core\Validation\UniqueFieldConstraintTest::providerTestEntityWithStringIdWithViolation()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Validation/UniqueFieldConstraintTest.php \Drupal\KernelTests\Core\Validation\UniqueFieldConstraintTest::providerTestEntityWithStringIdWithViolation()
  3. 11.x 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 108

Class

UniqueFieldConstraintTest
Tests the unique field value validation constraint.

Namespace

Drupal\KernelTests\Core\Validation

Code

public static 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' => [
      Random::machineName(),
    ],
  ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.