Skip to content

Commit 0f108dc

Browse files
committed
MAGETWO-67633: Advanced Pricing import validation results show 0 value for checked entities
1 parent 7432d16 commit 0f108dc

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ImportExport\Model\Import\Entity;
9+
10+
use Magento\Framework\App\Filesystem\DirectoryList;
11+
use Magento\ImportExport\Model\Import\Source\Csv;
12+
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
13+
14+
/**
15+
* Test class for \Magento\ImportExport\Model\Import\AbstractEntity
16+
*
17+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
18+
*/
19+
class EntityAbstractTest extends \PHPUnit\Framework\TestCase
20+
{
21+
/**
22+
* Test for method _saveValidatedBunches()
23+
*/
24+
public function testSaveValidatedBunches() : void
25+
{
26+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
27+
$filesystem = $objectManager->create(\Magento\Framework\Filesystem::class);
28+
$directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
29+
$source = new Csv(__DIR__ . '/_files/advanced_price_for_validation_test.csv', $directory);
30+
$source->rewind();
31+
32+
$eavConfig = $this->createMock(\Magento\Eav\Model\Config::class);
33+
$entityTypeMock = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
34+
$eavConfig->expects($this->any())->method('getEntityType')->willReturn($entityTypeMock);
35+
36+
/** @var $model AbstractEntity|\PHPUnit_Framework_MockObject_MockObject */
37+
$model = $this->getMockForAbstractClass(
38+
AbstractEntity::class,
39+
[
40+
$objectManager->get(\Magento\Framework\Json\Helper\Data::class),
41+
$objectManager->get(\Magento\ImportExport\Helper\Data::class),
42+
$objectManager->get(\Magento\ImportExport\Model\ResourceModel\Import\Data::class),
43+
$eavConfig,
44+
$objectManager->get(\Magento\Framework\App\ResourceConnection::class),
45+
$objectManager->get(\Magento\ImportExport\Model\ResourceModel\Helper::class),
46+
$objectManager->get(\Magento\Framework\Stdlib\StringUtils::class),
47+
$objectManager->get(ProcessingErrorAggregatorInterface::class),
48+
],
49+
'',
50+
true,
51+
false,
52+
true,
53+
['validateRow', 'getEntityTypeCode']
54+
);
55+
$model->expects($this->any())->method('validateRow')->willReturn(true);
56+
$model->expects($this->any())->method('getEntityTypeCode')->willReturn('catalog_product');
57+
58+
$model->setSource($source);
59+
60+
$method = new \ReflectionMethod($model, '_saveValidatedBunches');
61+
$method->setAccessible(true);
62+
$method->invoke($model);
63+
64+
$this->assertEquals(1, $model->getProcessedEntitiesCount());
65+
}
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sku,tier_price_website,tier_price_customer_group,tier_price_qty,tier_price,tier_price_value_type
2+
SimpleProduct,All Websites [USD],ALL GROUPS,100,50,Fixed
3+
SimpleProduct,All Websites [USD],ALL GROUPS,33,55,Fixed

0 commit comments

Comments
 (0)