You are here

public function ProductVariationAccessTest::testCreateAccess in Commerce Core 8.2

@covers ::checkCreateAccess

File

modules/product/tests/src/Kernel/ProductVariationAccessTest.php, line 110

Class

ProductVariationAccessTest
Tests the product variation access control.

Namespace

Drupal\Tests\commerce_product\Kernel

Code

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