public function ProductTest::testZeroProductWeightAndDimensions in Ubercart 8.4
Tests adding a product with weight = dimensions = 0.
File
- uc_product/
tests/ src/ Functional/ ProductTest.php, line 172
Class
- ProductTest
- Tests the product content type.
Namespace
Drupal\Tests\uc_product\FunctionalCode
public function testZeroProductWeightAndDimensions() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$edit = [
'title[0][value]' => $this
->randomMachineName(32),
'model[0][value]' => $this
->randomMachineName(8),
'price[0][value]' => mt_rand(1, 150),
'shippable[value]' => mt_rand(0, 1),
'weight[0][value]' => 0,
'weight[0][units]' => array_rand([
'lb' => 'Pounds',
'kg' => 'Kilograms',
'oz' => 'Ounces',
'g' => 'Grams',
]),
'dimensions[0][length]' => 0,
'dimensions[0][width]' => 0,
'dimensions[0][height]' => 0,
'dimensions[0][units]' => array_rand([
'in' => 'Inches',
'ft' => 'Feet',
'cm' => 'Centimeters',
'mm' => 'Millimeters',
]),
];
$this
->drupalGet('node/add/product');
$this
->submitForm($edit, 'Save');
// Check for product created message.
$assert
->pageTextContains(format_string('Product @title has been created.', [
'@title' => $edit['title[0][value]'],
]));
// Check that Weight and Dimensions are NOT shown on product page if
// they are set to zero.
$assert
->pageTextNotContains('Weight');
$assert
->pageTextNotContains('Dimensions');
}