Problem/Motivation

In core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php, $admin_user variable was unused.

Comments

shetpooja04 created an issue. See original summary.

shetpooja04’s picture

Assigned: shetpooja04 » Unassigned
Status: Active » Needs review
StatusFileSize
new645 bytes
new674.64 KB

Commit ID: 1ae0ed87

Link: https://git.drupalcode.org/project/drupal/-/commit/1ae0ed87961a92967314d3c289d25656058f54cc

File: core/modules/views/src/Tests/Handler/FieldEntityOperationsTest.php Line: 47

For Issue: https://www.drupal.org/project/drupal/issues/2476563 the variable was unused here

Please review

jijojoseph_zyxware’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for researching this, I agree with your findings that we don't need this variable.

Patch applied cleanly.

RTBC!!!

catch’s picture

Status: Reviewed & tested by the community » Needs work

If $admin_user isn't used, I don't think we need to create it at all.

jijojoseph_zyxware’s picture

StatusFileSize
new772 bytes

@catch You're Right. I have Created new patch.

jijojoseph_zyxware’s picture

Status: Needs work » Needs review
adhershmnair’s picture

Status: Needs review » Reviewed & tested by the community

I have reviewed Patch #5 and applied cleanly.
$admin_user is not used anywhere and also we don't want to create the user.

Thanks @jijojoseph_zyxware for the patch.

RTBC!!!

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php
@@ -66,11 +66,6 @@ class FieldEntityOperationsTest extends ViewTestBase {
-      'bypass node access',
-    ]);
     $this->drupalLogin($this->rootUser);
     $this->drupalGet('test-entity-operations');

Sorry looking at this in context I think there's another issue - we should be logging in as $admin_user instead of $this->rootUser for the test - then the variable will be used and we'll be testing what was intended. If the test fails with that change, we might need to adjust the permission (although it looks OK).

anmolgoyal74’s picture

Status: Needs work » Needs review
StatusFileSize
new1.56 KB
new1.9 KB

Addressed #8.
I think we need to update permissions as well.

Status: Needs review » Needs work

The last submitted patch, 9: remove-unused-variable-3175666-9.patch, failed testing. View results

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

sanjayk’s picture

Assigned: Unassigned » sanjayk

Working on it.

sanjayk’s picture

Assigned: sanjayk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.6 KB

As mentioned #8 added another permission and also changed '\Drupal\user\UserInterface' with '\Drupal\Core\Session\AccountInterface'.

lendude’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/tests/src/Functional/Handler/FieldEntityOperationsTest.php
@@ -66,12 +81,6 @@ public function testEntityOperations() {
-    $this->drupalLogin($this->rootUser);

Do we really need to do this in setUp() it's not like the is re-used anywhere? Why not just add the permission and do $this->drupalLogin($admin_user)?

paulocs’s picture

Assigned: Unassigned » paulocs

I'll work on it.

kapilv’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB
new857 bytes

Hear an updated patch.

paulocs’s picture

Status: Needs review » Needs work

@kapilkumar0324 if you are working in an issue you should assign it to your self, otherwise two people are working in the same issue and spend time with no reason (in that case I was working on it).

In my opinion it makes no sense to login in the setup() and I think @Lendude mentioned it in comment #14.
Another point is that now $adminUser in $this->drupalLogin($adminUser); is undefined so patch needs work.

For me it makes no sense to login in setup() but it is okay to create the user in setup().

I hide the files wrongly.

I'll provide a patch for it.

paulocs’s picture

Status: Needs work » Needs review
StatusFileSize
new1.6 KB
new830 bytes

Patch and interdiff.

The last submitted patch, , failed testing. View results

paulocs’s picture

Assigned: paulocs » Unassigned
sulfikar_s’s picture

Hello, @paulocs your patch applied cleanly. Also, it satisfies the requirements as in #8 by @catch and #14 by @Lendude.

Also your explanation seems correct about the $this->drupalLogin($adminUser); as it needs to be changed.

Thanks for the patch!

RTBC

changing the status to RTBC.

sulfikar_s’s picture

Status: Needs review » Reviewed & tested by the community
lendude’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.43 KB
new794 bytes

This still seems needlessly complicated adding the user in setUp. Much smaller change to just use the existing variable. ¯\_(ツ)_/¯

paulocs’s picture

Status: Needs review » Reviewed & tested by the community

Looks good too.

  • catch committed e18d1d1 on 9.2.x
    Issue #3175666 by paulocs, shetpooja04, Lendude, anmolgoyal74,...

  • catch committed 5c9b9c1 on 9.1.x
    Issue #3175666 by paulocs, shetpooja04, Lendude, anmolgoyal74,...
catch’s picture

Version: 9.2.x-dev » 9.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!

Status: Fixed » Closed (fixed)

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