function BlockContentEntityReferenceSelectionTest::testNoConditions

Tests with no conditions set.

Attributes

#[IgnoreDeprecations]

Throws

\Drupal\Core\Entity\EntityStorageException

File

core/modules/block_content/tests/src/Kernel/BlockContentEntityReferenceSelectionTest.php, line 150

Class

BlockContentEntityReferenceSelectionTest
Tests EntityReference selection handlers don't return non-reusable blocks.

Namespace

Drupal\Tests\block_content\Kernel

Code

public function testNoConditions() : void {
  $this->expectDeprecation('Automatically filtering block_content entity reference selection queries to only reusable blocks is deprecated in drupal:11.3.0 and is removed from drupal:12.0.0. Either add the condition manually in buildEntityQuery, or extend \\Drupal\\block_content\\Plugin\\EntityReferenceSelection\\BlockContentSelection. See https://www.drupal.org/node/3521459');
  $this->assertEquals($this->expectations['block_reusable'], $this->selectionHandler
    ->getReferenceableEntities());
  $this->blockNonReusable
    ->setReusable();
  $this->blockNonReusable
    ->save();
  // Ensure that the block is now returned as a referenceable entity.
  $this->assertEquals($this->expectations['both_blocks'], $this->selectionHandler
    ->getReferenceableEntities());
}

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