You are here

public function WorkspaceIntegrationTest::testEntityQueryWithoutConditions in Drupal 9

Same name and namespace in other branches
  1. 8 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 481

Class

WorkspaceIntegrationTest
Tests a complete publishing scenario across different workspaces.

Namespace

Drupal\Tests\workspaces\Kernel

Code

public function testEntityQueryWithoutConditions() {
  $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);
}