function SqlTest::testLoadEntitiesWithEmptyResult

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php \Drupal\Tests\views\Unit\Plugin\query\SqlTest::testLoadEntitiesWithEmptyResult()
  2. 10 core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php \Drupal\Tests\views\Unit\Plugin\query\SqlTest::testLoadEntitiesWithEmptyResult()
  3. 11.x core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php \Drupal\Tests\views\Unit\Plugin\query\SqlTest::testLoadEntitiesWithEmptyResult()

@covers ::loadEntities @covers ::assignEntitiesToResult

File

core/modules/views/tests/src/Unit/Plugin/query/SqlTest.php, line 249

Class

SqlTest
@coversDefaultClass \Drupal\views\Plugin\views\query\Sql

Namespace

Drupal\Tests\views\Unit\Plugin\query

Code

public function testLoadEntitiesWithEmptyResult() {
    $view = $this->prophesize('Drupal\\views\\ViewExecutable')
        ->reveal();
    $view_entity = $this->prophesize(ViewEntityInterface::class);
    $view_entity->get('base_table')
        ->willReturn('entity_first');
    $view_entity->get('base_field')
        ->willReturn('id');
    $view->storage = $view_entity->reveal();
    $entity_type_manager = $this->setupEntityTypes();
    $date_sql = $this->prophesize(DateSqlInterface::class);
    $messenger = $this->prophesize(MessengerInterface::class);
    $query = new Sql([], 'sql', [], $entity_type_manager->reveal(), $date_sql->reveal(), $messenger->reveal());
    $query->view = $view;
    $result = [];
    $query->addField('entity_first', 'id', 'id');
    $query->loadEntities($result);
    $this->assertEmpty($result);
}

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