function EntityStorageBaseTest::testLoad

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php \Drupal\Tests\Core\Entity\EntityStorageBaseTest::testLoad()
  2. 11.x core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php \Drupal\Tests\Core\Entity\EntityStorageBaseTest::testLoad()

@covers ::load

@dataProvider providerLoad

File

core/tests/Drupal/Tests/Core/Entity/EntityStorageBaseTest.php, line 50

Class

EntityStorageBaseTest
@coversDefaultClass \Drupal\Core\Entity\EntityStorageBase @group Entity

Namespace

Drupal\Tests\Core\Entity

Code

public function testLoad(string|null $expected, array $entity_fixture, string $query) : void {
    if (!is_null($expected)) {
        $expected = $this->generateEntityInterface($expected);
    }
    $entity_fixture = array_map([
        $this,
        'generateEntityInterface',
    ], $entity_fixture);
    $mock_base = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityStorageBase')
        ->disableOriginalConstructor()
        ->onlyMethods([
        'loadMultiple',
    ])
        ->getMockForAbstractClass();
    // load() always calls loadMultiple().
    $mock_base->expects($this->once())
        ->method('loadMultiple')
        ->with([
        $query,
    ])
        ->willReturn($entity_fixture);
    $this->assertEquals($expected, $mock_base->load($query));
}

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