public function AttributeTest::testAttributeUiProductOptions in Ubercart 8.4
Tests the "product options" page.
File
- uc_attribute/
tests/ src/ Functional/ AttributeTest.php, line 734
Class
- AttributeTest
- Tests the product attribute API.
Namespace
Drupal\Tests\uc_attribute\FunctionalCode
public function testAttributeUiProductOptions() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$product = $this
->createProduct();
$attribute = $this
->createAttribute([
'display' => 1,
]);
for ($i = 0; $i < 3; $i++) {
$option = $this
->createAttributeOption([
'aid' => $attribute->aid,
]);
$attribute->options[$option->oid] = $option;
}
uc_attribute_subject_save($attribute, 'product', $product
->id(), TRUE);
$this
->drupalGet('node/' . $product
->id() . '/edit/options');
// Check for attribute name.
$assert
->pageTextContains($attribute->name);
foreach ($attribute->options as $option) {
// Check for option name.
$assert
->pageTextContains($option->name);
// Check for option cost field.
$assert
->fieldValueEquals('attributes[' . $attribute->aid . '][options][' . $option->oid . '][cost]', uc_currency_format($option->cost, FALSE));
// Check for option price field.
$assert
->fieldValueEquals('attributes[' . $attribute->aid . '][options][' . $option->oid . '][price]', uc_currency_format($option->price, FALSE));
// Check for option weight field.
$assert
->fieldValueEquals('attributes[' . $attribute->aid . '][options][' . $option->oid . '][weight]', $option->weight);
}
}