You are here

public function CommerceProductUIAdminTest::testCommerceProductUIAccessProductTypes in Commerce Core 7

Test the access to the product types listing page.

File

modules/product/tests/commerce_product_ui.test, line 335
Functional tests for the commerce product ui module.

Class

CommerceProductUIAdminTest
Test the product and product type CRUD.

Code

public function testCommerceProductUIAccessProductTypes() {

  // Login with normal user.
  $this
    ->drupalLogin($this->store_customer);

  // Access to the product types listing.
  $this
    ->drupalGet('admin/commerce/products/types');
  $this
    ->assertResponse(403, t('Normal user is not able to access the product types listing page'));

  // Login with store admin.
  $this
    ->drupalLogin($this->store_admin);

  // Access to the product types listing.
  $this
    ->drupalGet('admin/commerce/products/types');
  $this
    ->assertResponse(200, t('Store admin user can access the product types listing page'));

  // Ensure that the link for create product types is in place.
  $this
    ->assertText(t('Add product type'), t('\'Add product type\' link is present in the admin list page'));

  // Get all the product types and check if they are listed.
  $product_types = commerce_product_types();
  foreach ($product_types as $type) {
    $this
      ->assertText($type['name'], t('%type is present in the product type listing', array(
      '%type' => $type['name'],
    )));
  }
}