Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293694

Correcting UserViewsFieldAccessTest

$
0
0

Follow-up to #2917584-49: Some tests only go green because they happen to run as UID1

Problem/Motivation

UserViewsFieldAccessTest extends FieldFieldAccessTestBase, where we have $userWithAccess instance with unexpected user/1 mode.

As a result, the UserViewsFieldAccessTest::testUserFields() checks access for user with full access, which is obviously not the goal of this test.

However, it would be good to keep assertions for user with 'administer users' permission too.

If we move this assertions to separate test, than another fun challenge arises. What to do with a commented code?

    // $this->assertFieldAccess('user', 'mail', 'druplicon@drop.org');
    // $this->assertFieldAccess('user', 'created', \Drupal::service('date.formatter')->format(123456));
    // $this->assertFieldAccess('user', 'changed', \Drupal::service('date.formatter')->format(REQUEST_TIME));

Proposed resolution

  1. Decouple test on two tests:
    • for user with 'view test entity field', 'access content' permissions
    • for user with 'administer users' permission
  2. Do not touch the commented code (just duplicate it to both tests), because we already have issue about it (#2464635: Follow-up: Enable additional tests for base entity field access checking in Views)
  3. Fix unexpected user/1 access for $userWithAccess in FieldFieldAccessTestBase, to prevent similar defects in the future.
  4. Override $userWithAccess inside UserViewsFieldAccessTest tests, and fixing $userWithAccess of FieldFieldAccessTestBase in #540008: Remove the special behavior of uid #1..

Remaining tasks

To choose the most suitable solution:

  • fix the root of the problem - in the FieldFieldAccessTestBase class (see #2)
  • fix only the effects of the problem in the UserViewsFieldAccessTest (see #4, #5).

User interface changes

API changes

Data model changes


Viewing all articles
Browse latest Browse all 293694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>