function InlineBlockUsageTest::testGetUnused

Same name in other branches
  1. 10 core/modules/layout_builder/tests/src/Kernel/InlineBlockUsageTest.php \Drupal\Tests\layout_builder\Kernel\InlineBlockUsageTest::testGetUnused()

Covers ::getUnused.

File

core/modules/layout_builder/tests/src/Kernel/InlineBlockUsageTest.php, line 75

Class

InlineBlockUsageTest
Class for testing the InlineBlockUsage service.

Namespace

Drupal\Tests\layout_builder\Kernel

Code

public function testGetUnused() : void {
    // Add a valid usage.
    $this->inlineBlockUsage
        ->addUsage('1', $this->entity);
    $this->assertEmpty($this->inlineBlockUsage
        ->getUnused());
    // Add an invalid usage.
    $this->database
        ->merge('inline_block_usage')
        ->keys([
        'block_content_id' => 2,
        'layout_entity_id' => NULL,
        'layout_entity_type' => NULL,
    ])
        ->execute();
    $this->assertCount(1, $this->inlineBlockUsage
        ->getUnused());
}

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