function WorkspaceIntegrationTest::testEntityQueryWithoutConditions

Same name in other branches
  1. 9 core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testEntityQueryWithoutConditions()
  2. 8.9.x core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testEntityQueryWithoutConditions()
  3. 11.x core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php \Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest::testEntityQueryWithoutConditions()

Tests entity query overrides without any conditions.

File

core/modules/workspaces/tests/src/Kernel/WorkspaceIntegrationTest.php, line 563

Class

WorkspaceIntegrationTest
Tests a complete publishing scenario across different workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

public function testEntityQueryWithoutConditions() : void {
    $this->initializeWorkspacesModule();
    $this->switchToWorkspace('stage');
    // Add a workspace-specific revision to a pre-existing node.
    $node = $this->entityTypeManager
        ->getStorage('node')
        ->load(2);
    $node->title->value = 'stage - 2 - r3 - published';
    $node->save();
    $query = $this->entityTypeManager
        ->getStorage('node')
        ->getQuery()
        ->accessCheck(FALSE);
    $query->sort('nid');
    $query->pager(1);
    $result = $query->execute();
    $this->assertSame([
        1 => '1',
    ], $result);
    $query = $this->entityTypeManager
        ->getStorage('node')
        ->getQuery()
        ->accessCheck(FALSE);
    $query->sort('nid', 'DESC');
    $query->pager(10);
    $result = $query->execute();
    $this->assertSame([
        3 => '2',
        1 => '1',
    ], $result);
}

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