function BlockValidationTest::testWeightValidation

Tests validating weight.

File

core/modules/block/tests/src/Kernel/BlockValidationTest.php, line 160

Class

BlockValidationTest
Tests validation of block entities.

Namespace

Drupal\Tests\block\Kernel

Code

public function testWeightValidation() : void {
    $this->entity
        ->set('weight', $this->randomString());
    $this->assertValidationErrors([
        'weight' => [
            'This value should be a valid number.',
            'This value should be of the correct primitive type.',
        ],
    ]);
    $this->entity
        ->set('weight', 10);
    $this->assertValidationErrors([]);
}

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