You are here

public function WishlistItemAccessTest::testCreateAccess in Commerce Wishlist 8.3

@covers ::checkCreateAccess

File

tests/src/Kernel/WishlistItemAccessTest.php, line 110

Class

WishlistItemAccessTest
Tests the wishlist item access control.

Namespace

Drupal\Tests\commerce_wishlist\Kernel

Code

public function testCreateAccess() {
  $access_control_handler = \Drupal::entityTypeManager()
    ->getAccessControlHandler('commerce_wishlist_item');
  $account = $this
    ->createUser([], [
    'access content',
  ]);
  $this
    ->assertFalse($access_control_handler
    ->createAccess('test', $account));
  $account = $this
    ->createUser([], [
    'administer commerce_wishlist',
  ]);
  $this
    ->assertTrue($access_control_handler
    ->createAccess('default', $account));
  $this
    ->assertTrue($access_control_handler
    ->createAccess('commerce_product_variation', $account));
  $account = $this
    ->createUser([], [
    'manage commerce_product_variation commerce_wishlist_item',
  ]);
  $this
    ->assertTrue($access_control_handler
    ->createAccess('commerce_product_variation', $account));
}