public function PriceTest::testImportSellPrice in Commerce Feeds 8
Tests importing product variations.
File
- tests/
src/ Kernel/ Target/ PriceTest.php, line 57
Class
- PriceTest
- @coversDefaultClass \Drupal\commerce_feeds\Feeds\Target\Price @group commerce_feeds
Namespace
Drupal\Tests\commerce_feeds\Kernel\TargetCode
public function testImportSellPrice() {
$this->feedType
->addMapping([
'target' => 'price',
'map' => [
'number' => 'price',
],
'settings' => [
'currency_code' => 'USD',
],
]);
$this->feedType
->save();
// Import.
$feed = $this
->createFeed($this->feedType
->id(), [
'source' => $this
->resourcesPath() . '/product_variations.csv',
]);
$feed
->import();
// Assert that three product variations were created.
$variations = ProductVariation::loadMultiple();
$this
->assertCount(3, $variations);
// Check expected prices.
$expected = [
1 => 100,
2 => 24.52,
3 => 0,
];
foreach ($expected as $id => $value) {
$price = $variations[$id]
->getPrice();
$this
->assertEquals($value, $price
->getNumber());
$this
->assertEquals('USD', $price
->getCurrencyCode());
}
}