Skip to content

Commit accb999

Browse files
committed
MAGETWO-83094: Products Ordered Report exported CSV is empty
1 parent 6889d50 commit accb999

File tree

4 files changed

+43
-32
lines changed

4 files changed

+43
-32
lines changed

dev/tests/integration/testsuite/Magento/Quote/Model/QuoteRepositoryTest.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,19 @@ class QuoteRepositoryTest extends \PHPUnit_Framework_TestCase
4444
*/
4545
private $filterBuilder;
4646

47+
/**
48+
* @var array
49+
*/
50+
private $addressData;
51+
4752
protected function setUp()
4853
{
4954
$this->objectManager = Bootstrap::getObjectManager();
5055
$this->quoteRepository = $this->objectManager->create(QuoteRepository::class);
5156
$this->searchCriteriaBuilder = $this->objectManager->create(SearchCriteriaBuilder::class);
5257
$this->filterBuilder = $this->objectManager->create(FilterBuilder::class);
58+
59+
$this->addressData = require __DIR__ . '/../../Sales/_files/address_data.php';
5360
}
5461

5562
/**
@@ -105,15 +112,13 @@ public function testGetListDoubleCall()
105112
*/
106113
public function testSaveWithNotExistingCustomerAddress()
107114
{
108-
$addressData = include __DIR__ . '/../../Sales/_files/address_data.php';
109-
110115
/** @var QuoteAddress $billingAddress */
111-
$billingAddress = $this->objectManager->create(QuoteAddress::class, ['data' => $addressData]);
116+
$billingAddress = $this->objectManager->create(QuoteAddress::class, ['data' => $this->addressData]);
112117
$billingAddress->setAddressType(QuoteAddress::ADDRESS_TYPE_BILLING)
113118
->setCustomerAddressId('not_existing');
114119

115120
/** @var QuoteAddress $shippingAddress */
116-
$shippingAddress = $this->objectManager->create(QuoteAddress::class, ['data' => $addressData]);
121+
$shippingAddress = $this->objectManager->create(QuoteAddress::class, ['data' => $this->addressData]);
117122
$shippingAddress->setAddressType(QuoteAddress::ADDRESS_TYPE_SHIPPING)
118123
->setCustomerAddressId('not_existing');
119124

@@ -149,6 +154,8 @@ public function testSaveWithNotExistingCustomerAddress()
149154
->getAddress()
150155
->getCustomerAddressId()
151156
);
157+
158+
$this->quoteRepository->delete($quote);
152159
}
153160

154161
/**
@@ -178,22 +185,18 @@ private function getSearchCriteria($filterValue)
178185
*/
179186
protected function performAssertions($searchResult)
180187
{
181-
$expectedExtensionAttributes = [
182-
'firstname' => 'firstname',
183-
'lastname' => 'lastname',
184-
'email' => 'admin@example.com'
185-
];
186-
187188
$items = $searchResult->getItems();
189+
$this->assertNotEmpty($items, 'Search result is empty.');
190+
188191
/** @var CartInterface $actualQuote */
189192
$actualQuote = array_pop($items);
190193
/** @var UserInterface $testAttribute */
191194
$testAttribute = $actualQuote->getExtensionAttributes()->getQuoteTestAttribute();
192195

193196
$this->assertInstanceOf(CartInterface::class, $actualQuote);
194197
$this->assertEquals('test01', $actualQuote->getReservedOrderId());
195-
$this->assertEquals($expectedExtensionAttributes['firstname'], $testAttribute->getFirstName());
196-
$this->assertEquals($expectedExtensionAttributes['lastname'], $testAttribute->getLastName());
197-
$this->assertEquals($expectedExtensionAttributes['email'], $testAttribute->getEmail());
198+
$this->assertEquals($this->addressData['firstname'], $testAttribute->getFirstName());
199+
$this->assertEquals($this->addressData['lastname'], $testAttribute->getLastName());
200+
$this->assertEquals($this->addressData['email'], $testAttribute->getEmail());
198201
}
199202
}

dev/tests/integration/testsuite/Magento/Quote/_files/quote.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,25 @@
88
Bootstrap::getInstance()->loadArea(Magento\Framework\App\Area::AREA_FRONTEND);
99

1010
$product = Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Product::class);
11-
$product->setTypeId('simple')
12-
->setId(1)
11+
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
1312
->setAttributeSetId(4)
1413
->setName('Simple Product')
1514
->setSku('simple')
1615
->setPrice(10)
17-
->setTaxClassId(0)
1816
->setMetaTitle('meta title')
1917
->setMetaKeyword('meta keyword')
2018
->setMetaDescription('meta description')
2119
->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
2220
->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
23-
->setStockData(
24-
[
25-
'qty' => 100,
26-
'is_in_stock' => 1,
27-
]
28-
);
21+
->setStockData([
22+
'use_config_manage_stock' => 1,
23+
'qty' => 100,
24+
'is_qty_decimal' => 0,
25+
'is_in_stock' => 1,
26+
]);
2927

3028
/** @var Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
31-
$productRepository = Bootstrap::getObjectManager()
32-
->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
29+
$productRepository = Bootstrap::getObjectManager()->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
3330
$product = $productRepository->save($product);
3431

3532
$addressData = include __DIR__ . '/../../Sales/_files/address_data.php';

dev/tests/integration/testsuite/Magento/Quote/_files/quote_on_second_website_rollback.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
$quote->delete();
2424
}
2525

26+
$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
27+
try {
28+
$product2 = $productRepository->get('simple-2', false, null, true);
29+
30+
// Remove product stock registry data.
31+
$stockRegistryStorage = $objectManager->get(\Magento\CatalogInventory\Model\StockRegistryStorage::class);
32+
$stockRegistryStorage->removeStockItem($product2->getId());
33+
$stockRegistryStorage->removeStockStatus($product2->getId());
34+
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
35+
//Product already removed
36+
}
37+
2638
$registry->unregister('isSecureArea');
2739
$registry->register('isSecureArea', false);
2840

dev/tests/integration/testsuite/Magento/Quote/_files/quote_rollback.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@
2424
try {
2525
$product = $productRepository->get('simple', false, null, true);
2626
$productRepository->delete($product);
27+
28+
// Remove product stock registry data.
29+
$stockRegistryStorage = Bootstrap::getObjectManager()->get(
30+
\Magento\CatalogInventory\Model\StockRegistryStorage::class
31+
);
32+
$stockRegistryStorage->removeStockItem($product->getId());
33+
$stockRegistryStorage->removeStockStatus($product->getId());
2734
} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) {
2835
//Product already removed
2936
}
3037

31-
// Remove product stock registry data.
32-
/** @var \Magento\CatalogInventory\Model\StockRegistryStorage $stockRegistryStorage */
33-
$stockRegistryStorage = Bootstrap::getObjectManager()->get(
34-
\Magento\CatalogInventory\Model\StockRegistryStorage::class
35-
);
36-
$stockRegistryStorage->removeStockItem(1);
37-
$stockRegistryStorage->removeStockStatus(1);
38-
3938
$registry->unregister('isSecureArea');
4039
$registry->register('isSecureArea', false);

0 commit comments

Comments
 (0)