function NodeOperationAccessTest::providerTestRevisionOperations

Same name in other branches
  1. 9 core/modules/node/tests/src/Unit/NodeOperationAccessTest.php \Drupal\Tests\node\Unit\NodeOperationAccessTest::providerTestRevisionOperations()
  2. 11.x core/modules/node/tests/src/Unit/NodeOperationAccessTest.php \Drupal\Tests\node\Unit\NodeOperationAccessTest::providerTestRevisionOperations()

Data provider for revisionOperationsProvider.

Return value

array Data for testing.

File

core/modules/node/tests/src/Unit/NodeOperationAccessTest.php, line 132

Class

NodeOperationAccessTest
Tests node operations.

Namespace

Drupal\Tests\node\Unit

Code

public static function providerTestRevisionOperations() {
    $data = [];
    // Tests 'bypass node access' never works on revision operations.
    $data['bypass, view all revisions'] = [
        'view all revisions',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'bypass node access',
                TRUE,
            ],
        ],
        FALSE,
    ];
    $data['bypass, view revision'] = [
        'view revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'bypass node access',
                TRUE,
            ],
        ],
        FALSE,
    ];
    $data['bypass, revert'] = [
        'revert revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'bypass node access',
                TRUE,
            ],
        ],
        FALSE,
    ];
    $data['bypass, delete revision'] = [
        'delete revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'bypass node access',
                TRUE,
            ],
        ],
        FALSE,
    ];
    $data['view all revisions'] = [
        'view all revisions',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'view all revisions',
                TRUE,
            ],
        ],
        TRUE,
    ];
    $data['view all revisions with view access'] = [
        'view all revisions',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'view all revisions',
                TRUE,
            ],
            // Bypass for 'view' operation.
[
                'bypass node access',
                TRUE,
            ],
        ],
        TRUE,
    ];
    $data['view revision, without view access'] = [
        'view revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'view all revisions',
                TRUE,
            ],
        ],
        FALSE,
    ];
    $data['view revision, with view access'] = [
        'view revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'view all revisions',
                TRUE,
            ],
            // Bypass for 'view' operation.
[
                'bypass node access',
                TRUE,
            ],
        ],
        TRUE,
    ];
    // Cannot revert if no update access.
    $data['revert, without update access, non default'] = [
        'revert revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'revert all revisions',
                TRUE,
            ],
        ],
        FALSE,
        FALSE,
    ];
    // Can revert if has update access.
    $data['revert, with update access, non default'] = [
        'revert revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'revert all revisions',
                TRUE,
            ],
            // Bypass for 'update' operation.
[
                'bypass node access',
                TRUE,
            ],
        ],
        TRUE,
        FALSE,
    ];
    // Can never revert default revision.
    $data['revert, with update access, default revision'] = [
        'revert revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'revert all revisions',
                TRUE,
            ],
            // Bypass for 'update' operation.
[
                'bypass node access',
                TRUE,
            ],
        ],
        FALSE,
        TRUE,
    ];
    // Cannot delete non default revision if no delete access.
    $data['delete revision, without delete access, non default'] = [
        'delete revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'delete all revisions',
                TRUE,
            ],
        ],
        FALSE,
        FALSE,
    ];
    // Can delete non default revision if delete access.
    $data['delete revision, with delete access, non default'] = [
        'delete revision',
        [
            [
                'access content',
                TRUE,
            ],
            [
                'delete all revisions',
                TRUE,
            ],
            // Bypass for 'delete' operation.
[
                'bypass node access',
                TRUE,
            ],
        ],
        TRUE,
        FALSE,
    ];
    return $data;
}

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