function UniqueFieldConstraintTest::providerTestEntityWithStringIdWithViolation

Same name in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Validation/UniqueFieldConstraintTest.php \Drupal\KernelTests\Core\Validation\UniqueFieldConstraintTest::providerTestEntityWithStringIdWithViolation()
  2. 10 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 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(),
        ],
    ];
}

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