public function PackageTypeTest::testPackageTypeEditing in Commerce Shipping 8.2
Testing editing a package type.
File
- tests/
src/ Functional/ PackageTypeTest.php, line 69
Class
- PackageTypeTest
- Tests the package type UI.
Namespace
Drupal\Tests\commerce_shipping\FunctionalCode
public function testPackageTypeEditing() {
$values = [
'id' => 'edit_example',
'label' => 'Edit example',
'dimensions' => [
'length' => '15',
'width' => '15',
'height' => '15',
'unit' => 'm',
],
'weight' => [
'number' => 0,
'unit' => 'g',
],
];
$package_type = $this
->createEntity('commerce_package_type', $values);
$this
->drupalGet('admin/commerce/config/package-types/manage/' . $package_type
->id());
$edit = [
'dimensions[length]' => '20',
'weight[number]' => '2',
'weight[unit]' => 'lb',
];
$this
->submitForm($edit, 'Save');
\Drupal::entityTypeManager()
->getStorage('commerce_package_type')
->resetCache();
$package_type = PackageType::load('edit_example');
$this
->assertEquals('edit_example', $package_type
->id());
$this
->assertEquals('Edit example', $package_type
->label());
$this
->assertEquals('20', $package_type
->getDimensions()['length']);
$this
->assertEquals('15', $package_type
->getDimensions()['width']);
$this
->assertEquals('15', $package_type
->getDimensions()['height']);
$this
->assertEquals('m', $package_type
->getDimensions()['unit']);
$this
->assertEquals('2', $package_type
->getWeight()['number']);
$this
->assertEquals('lb', $package_type
->getWeight()['unit']);
}