You are here

public function CatalogTest::testCatalogAttribute in Ubercart 8.4

Tests the catalog with a product with attributes.

File

uc_catalog/tests/src/Functional/CatalogTest.php, line 65

Class

CatalogTest
Tests for the Ubercart catalog.

Namespace

Drupal\Tests\uc_catalog\Functional

Code

public function testCatalogAttribute() {

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();
  $this
    ->drupalLogin($this->adminUser);
  $term = $this
    ->createCatalogTerm();
  $product = $this
    ->createProduct([
    'taxonomy_catalog' => [
      $term
        ->id(),
    ],
  ]);
  $attribute = $this
    ->createAttribute([
    'display' => 0,
  ]);
  uc_attribute_subject_save($attribute, 'product', $product
    ->id());
  $this
    ->drupalGet('catalog/' . $term
    ->id());
  $this
    ->submitForm([], 'Add to cart');
  $assert
    ->pageTextNotContains($product
    ->label() . ' added to your shopping cart.');
  $assert
    ->pageTextContains('This product has options that need to be selected before purchase. Please select them in the form below.');
}