Problem/Motivation

The test class in core/modules/node/tests/src/Functional/NodeTranslationUITest.php uses a regular database query instead of using an entity query.

Proposed resolution

Replace the regular database query with an entity query.

Remaining tasks

TBD

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

TBD

Comments

daffie created an issue. See original summary.

daffie’s picture

Status: Active » Needs review
StatusFileSize
new1.07 KB

Patch changes the db query to an entity query.

snehalgaikwad’s picture

Assigned: Unassigned » snehalgaikwad
snehalgaikwad’s picture

Assigned: snehalgaikwad » Unassigned
StatusFileSize
new1.37 KB

Removed use statement for database, which was not in use.

daffie’s picture

@snehalgaikwad: Can you add an interdiff.txt. It makes reviewing the changes that you made a lot easier.

daffie’s picture

@snehalgaikwad: Can you say that the change from a database query to an entity query is done correctly?

hardik_patel_12’s picture

StatusFileSize
new592 bytes

Interfdiif for patch at #4 and #2. After replacing Database::getConnection()->query with entityQuery 'use Drupal\Core\Database\Database;' becomes unused .

hardik_patel_12’s picture

Status: Needs review » Reviewed & tested by the community

All the test cases are passed verified on local , so moving to RTBC.

pratik_kamble’s picture

Issue tags: +Bug Smash Initiative
pratik_kamble’s picture

Issue tags: -Bug Smash Initiative
catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/node/tests/src/Functional/NodeTranslationUITest.php
@@ -279,8 +278,13 @@ public function testDisabledBundle() {
-    $this->assertCount(0, $rows);
+    $nids = \Drupal::entityQueryAggregate('node')
+      ->aggregate('nid', 'COUNT')
+      ->condition('type', $this->bundle)
+      ->conditionAggregate('nid', 'COUNT', 2, '>=')
+      ->groupBy('nid')
+      ->execute();

This should have an ->accessCheck(FALSE).

hardik_patel_12’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB
new619 bytes

Adding the requested ->accessCheck(FALSE) to EntityQuery.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

Change looks like what @catch requested.
Back to RTBC.

  • catch committed 308db36 on 9.1.x
    Issue #3151968 by Hardik_Patel_12, daffie, snehalgaikwad: Replace the...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 308db36 and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.