public function PriceListItemTest::testEdit in Commerce Pricelist 8.2
Tests editing a price list item.
File
- tests/
src/ Functional/ PriceListItemTest.php, line 129
Class
- PriceListItemTest
- Tests the price list item UI.
Namespace
Drupal\Tests\commerce_pricelist\FunctionalCode
public function testEdit() {
$price_list_item = $this
->createEntity('commerce_pricelist_item', [
'type' => 'commerce_product_variation',
'price_list_id' => $this->priceList
->id(),
'purchasable_entity' => $this->firstVariation
->id(),
'quantity' => '10',
'price' => new Price('50', 'USD'),
]);
$this
->drupalGet($price_list_item
->toUrl('edit-form'));
$this
->submitForm([
'purchasable_entity[0][target_id]' => 'Blue shirt (2)',
'quantity[0][value]' => '9',
'price[0][number]' => 40,
], 'Save');
$this
->assertSession()
->pageTextContains('Saved the Blue shirt: $40.00 price.');
\Drupal::service('entity_type.manager')
->getStorage('commerce_pricelist_item')
->resetCache([
$price_list_item
->id(),
]);
$price_list_item = PriceListItem::load(1);
$this
->assertEquals($this->secondVariation
->id(), $price_list_item
->getPurchasableEntityId());
$this
->assertEquals('9', $price_list_item
->getQuantity());
$this
->assertEquals(new Price('40', 'USD'), $price_list_item
->getPrice());
}