public function PriceListRepositoryTest::testCustomers in Commerce Pricelist 8.2
Tests customer-based loading.
@covers ::loadItem @covers ::loadItems
File
- tests/
src/ Kernel/ PriceListRepositoryTest.php, line 131
Class
- PriceListRepositoryTest
- Tests the price list repository.
Namespace
Drupal\Tests\commerce_pricelist\KernelCode
public function testCustomers() {
$repository = $this->container
->get('commerce_pricelist.repository');
$customer = $this
->createUser();
$this->priceList
->setCustomer($customer);
$this->priceList
->save();
$context = new Context($this->user, $this->store);
$price_list_item = $repository
->loadItem($this->variation, 1, $context);
$this
->assertEmpty($price_list_item);
$context = new Context($customer, $this->store);
$price_list_item = $repository
->loadItem($this->variation, 1, $context);
$this
->assertEquals(new Price('5.00', 'USD'), $price_list_item
->getPrice());
}