function BlockValidationTest::testWeightCannotBeNull

Same name and namespace in other branches
  1. 11.x core/modules/block/tests/src/Kernel/BlockValidationTest.php \Drupal\Tests\block\Kernel\BlockValidationTest::testWeightCannotBeNull()

Tests weight cannot be null.

Attributes

#[IgnoreDeprecations]

File

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

Class

BlockValidationTest
Tests validation of block entities.

Namespace

Drupal\Tests\block\Kernel

Code

public function testWeightCannotBeNull() : void {
  $this->entity
    ->set('weight', NULL);
  $this->assertNull($this->entity
    ->getWeight());
  $this->expectDeprecation('Saving a block with a non-integer weight is deprecated in drupal:11.1.0 and removed in drupal:12.0.0. See https://www.drupal.org/node/3462474');
  $this->entity
    ->save();
}

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