Skip to content

Commit 8c95a82

Browse files
Merge branch '2.3-develop' of https://github.com/magento/magento2ce into MAGETWO-85904-2.3
2 parents e917415 + 8954d07 commit 8c95a82

File tree

243 files changed

+6312
-3029
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+6312
-3029
lines changed

app/code/Magento/Backend/Test/Unit/Model/Menu/ConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function testGetMenuWithCachedObjectReturnsUnserializedObject()
9696
$this->assertEquals($this->menuMock, $this->model->getMenu());
9797
}
9898

99-
public function testGetMenuWithNotCachedObjectBuidlsObject()
99+
public function testGetMenuWithNotCachedObjectBuildsObject()
100100
{
101101
$this->cacheInstanceMock->expects(
102102
$this->at(0)

app/code/Magento/Braintree/Test/Unit/Gateway/Config/CanVoidHandlerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testHandleNotOrderPayment()
3939
static::assertFalse($voidHandler->handle($subject));
4040
}
4141

42-
public function testHandleSomeAmoutWasPaid()
42+
public function testHandleSomeAmountWasPaid()
4343
{
4444
$paymentDO = $this->createMock(PaymentDataObjectInterface::class);
4545
$subject = [

app/code/Magento/Braintree/Test/Unit/Model/Report/TransactionsCollectionTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ public function testGetItemsEmptyCollection()
125125
*/
126126
public function testGetItemsWithLimit()
127127
{
128-
$transations = range(1, TransactionsCollection::TRANSACTION_MAXIMUM_COUNT + 10);
128+
$transactions = range(1, TransactionsCollection::TRANSACTION_MAXIMUM_COUNT + 10);
129129

130130
$this->filterMapperMock->expects($this->once())
131131
->method('getFilter')
132132
->willReturn(new BraintreeSearchNodeStub());
133133

134134
$this->braintreeAdapterMock->expects($this->once())
135135
->method('search')
136-
->willReturn($transations);
136+
->willReturn($transactions);
137137

138138
$this->entityFactoryMock->expects($this->exactly(TransactionsCollection::TRANSACTION_MAXIMUM_COUNT))
139139
->method('create')
@@ -157,15 +157,15 @@ public function testGetItemsWithLimit()
157157
*/
158158
public function testGetItemsWithNullLimit()
159159
{
160-
$transations = range(1, TransactionsCollection::TRANSACTION_MAXIMUM_COUNT + 10);
160+
$transactions = range(1, TransactionsCollection::TRANSACTION_MAXIMUM_COUNT + 10);
161161

162162
$this->filterMapperMock->expects($this->once())
163163
->method('getFilter')
164164
->willReturn(new BraintreeSearchNodeStub());
165165

166166
$this->braintreeAdapterMock->expects($this->once())
167167
->method('search')
168-
->willReturn($transations);
168+
->willReturn($transactions);
169169

170170
$this->entityFactoryMock->expects($this->exactly(TransactionsCollection::TRANSACTION_MAXIMUM_COUNT))
171171
->method('create')

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,7 @@ public function testPrepareForCartAdvancedParentClassReturnString()
13651365
/**
13661366
* @return void
13671367
*/
1368-
public function testPrepareForCartAdvancedAllrequiredOption()
1368+
public function testPrepareForCartAdvancedAllRequiredOption()
13691369
{
13701370
/** @var \PHPUnit_Framework_MockObject_MockObject|DefaultType $group */
13711371
$group = $this->getMockBuilder(\Magento\Catalog\Model\Product\Option\Type\DefaultType::class)

app/code/Magento/Bundle/view/frontend/templates/sales/order/creditmemo/items/renderer.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
<?php $items = $block->getChildren($parentItem) ?>
1414
<?php $_order = $block->getItem()->getOrderItem()->getOrder() ?>
15-
<?php $_count = count($items) ?>
1615
<?php $_index = 0 ?>
1716

1817
<?php $_prevOptionId = '' ?>

app/code/Magento/Bundle/view/frontend/templates/sales/order/invoice/items/renderer.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<?php $_order = $block->getItem()->getOrderItem()->getOrder() ?>
1313

1414
<?php $items = $block->getChildren($parentItem) ?>
15-
<?php $_count = count($items) ?>
1615
<?php $_index = 0 ?>
1716

1817
<?php $_prevOptionId = '' ?>

app/code/Magento/Bundle/view/frontend/templates/sales/order/items/renderer.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
?>
1111
<?php $parentItem = $block->getItem() ?>
1212
<?php $items = array_merge([$parentItem], $parentItem->getChildrenItems()); ?>
13-
<?php $_count = count($items) ?>
1413
<?php $_index = 0 ?>
1514

1615
<?php $_prevOptionId = '' ?>

app/code/Magento/Bundle/view/frontend/templates/sales/order/shipment/items/renderer.phtml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
<?php $parentItem = $block->getItem() ?>
1313
<?php $items = array_merge([$parentItem->getOrderItem()], $parentItem->getOrderItem()->getChildrenItems()) ?>
1414
<?php $shipItems = $block->getChildren($parentItem) ?>
15-
<?php $_count = count($items) ?>
1615
<?php $_index = 0 ?>
1716

1817
<?php $_prevOptionId = '' ?>

app/code/Magento/Catalog/Model/ResourceModel/Product/Link/DeleteHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function execute($entityType, $entity)
7272
$linkedProduct = $this->productRepository->get($entity->getLinkedProductSku());
7373
$product = $this->productRepository->get($entity->getSku());
7474
$linkTypesToId = $this->linkTypeProvider->getLinkTypes();
75-
$prodyctHydrator = $this->metadataPool->getHydrator(ProductInterface::class);
76-
$productData = $prodyctHydrator->extract($product);
75+
$productHydrator = $this->metadataPool->getHydrator(ProductInterface::class);
76+
$productData = $productHydrator->extract($product);
7777
$linkId = $this->linkResource->getProductLinkId(
7878
$productData[$this->metadataPool->getMetadata(ProductInterface::class)->getLinkField()],
7979
$linkedProduct->getId(),

app/code/Magento/Catalog/Model/ResourceModel/Product/Link/SaveHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public function execute($entityType, $entity)
9797

9898
try {
9999
$linkTypesToId = $this->linkTypeProvider->getLinkTypes();
100-
$prodyctHydrator = $this->metadataPool->getHydrator(ProductInterface::class);
101-
$productData = $prodyctHydrator->extract($product);
100+
$productHydrator = $this->metadataPool->getHydrator(ProductInterface::class);
101+
$productData = $productHydrator->extract($product);
102102
$this->linkResource->saveProductLinks(
103103
$productData[$this->metadataPool->getMetadata(ProductInterface::class)->getLinkField()],
104104
$links,

app/code/Magento/Catalog/Test/Unit/Block/Category/ViewTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ protected function tearDown()
3131
public function testGetIdentities()
3232
{
3333
$categoryTag = ['catalog_category_1'];
34-
$currentCatogoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
35-
$currentCatogoryMock->expects($this->once())->method('getIdentities')->will($this->returnValue($categoryTag));
36-
$this->block->setCurrentCategory($currentCatogoryMock);
34+
$currentCategoryMock = $this->createMock(\Magento\Catalog\Model\Category::class);
35+
$currentCategoryMock->expects($this->once())->method('getIdentities')->will($this->returnValue($categoryTag));
36+
$this->block->setCurrentCategory($currentCategoryMock);
3737
$this->assertEquals($categoryTag, $this->block->getIdentities());
3838
}
3939
}

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function testExecuteWithGenericException()
115115
$layoutMock->expects($this->once())
116116
->method('getMessagesBlock')
117117
->willReturn($messageBlock);
118-
$wysiwigConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
118+
$wysiwygConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
119119
->disableOriginalConstructor()
120120
->getMock();
121121
$registry = $this->getMockBuilder(Registry::class)
@@ -135,7 +135,7 @@ public function testExecuteWithGenericException()
135135
$this->objectManager->expects($this->any())
136136
->method('get')
137137
->withConsecutive([Registry::class], [Registry::class], [\Magento\Cms\Model\Wysiwyg\Config::class])
138-
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwigConfig]]);
138+
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
139139
$categoryMock->expects($this->once())
140140
->method('move')
141141
->willThrowException(new \Exception(
@@ -189,7 +189,7 @@ public function testExecuteWithLocaliedException()
189189
$layoutMock->expects($this->once())
190190
->method('getMessagesBlock')
191191
->willReturn($messageBlock);
192-
$wysiwigConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
192+
$wysiwygConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
193193
->disableOriginalConstructor()
194194
->getMock();
195195
$registry = $this->getMockBuilder(Registry::class)
@@ -209,7 +209,7 @@ public function testExecuteWithLocaliedException()
209209
$this->objectManager->expects($this->any())
210210
->method('get')
211211
->withConsecutive([Registry::class], [Registry::class], [\Magento\Cms\Model\Wysiwyg\Config::class])
212-
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwigConfig]]);
212+
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
213213
$this->messageManager->expects($this->once())
214214
->method('addExceptionMessage');
215215
$this->messageManager->expects($this->once())
@@ -261,7 +261,7 @@ public function testSuccessfullCategorySave()
261261
$layoutMock->expects($this->once())
262262
->method('getMessagesBlock')
263263
->willReturn($messageBlock);
264-
$wysiwigConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
264+
$wysiwygConfig = $this->getMockBuilder(\Magento\Cms\Model\Wysiwyg\Config::class)
265265
->disableOriginalConstructor()
266266
->getMock();
267267
$registry = $this->getMockBuilder(Registry::class)
@@ -281,7 +281,7 @@ public function testSuccessfullCategorySave()
281281
$this->objectManager->expects($this->any())
282282
->method('get')
283283
->withConsecutive([Registry::class], [Registry::class], [\Magento\Cms\Model\Wysiwyg\Config::class])
284-
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwigConfig]]);
284+
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
285285
$this->messageManager->expects($this->once())
286286
->method('getMessages')
287287
->with(true)

app/code/Magento/Catalog/Test/Unit/CustomerData/ProductsRenderInfoSectionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,18 +134,18 @@ public function testGetSectionData()
134134
->expects($this->once())
135135
->method('create')
136136
->willReturn($filterMock);
137-
$searchCritera = $this->createMock(SearchCriteria::class);
137+
$searchCriteria = $this->createMock(SearchCriteria::class);
138138
$this->searchCriteriaBuilderMock
139139
->expects($this->once())
140140
->method('addFilters')
141141
->with([$filterMock])
142142
->willReturnSelf();
143143
$this->searchCriteriaBuilderMock->expects($this->once())
144144
->method('create')
145-
->willReturn($searchCritera);
145+
->willReturn($searchCriteria);
146146
$this->productRenderRepositoryMock->expects($this->once())
147147
->method('getList')
148-
->with($searchCritera, 3, 'UAH')
148+
->with($searchCriteria, 3, 'UAH')
149149
->willReturn($searchResult);
150150
$searchResult->expects($this->any())
151151
->method('getItems')
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogGraphQl\Model;
8+
9+
use Magento\Framework\GraphQl\Config\Data\TypeResolverInterface;
10+
use Magento\Framework\Exception\InputException;
11+
12+
/**
13+
* {@inheritdoc}
14+
*/
15+
class ConcreteTypeResolver implements TypeResolverInterface
16+
{
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public function resolveType(array $data)
21+
{
22+
if (!isset($data['type_id'])) {
23+
throw new InputException(
24+
__('%1 key doesn\'t exist in product data', [$data['type_id']])
25+
);
26+
}
27+
28+
if ($data['type_id'] == 'simple') {
29+
return 'SimpleProduct';
30+
}
31+
32+
return null;
33+
}
34+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogGraphQl\Model\Config;
8+
9+
use Magento\Framework\Config\ReaderInterface;
10+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
11+
use Magento\Framework\GraphQl\Type\Entity\MapperInterface;
12+
use Magento\Framework\Reflection\TypeProcessor;
13+
use Magento\EavGraphQl\Model\Resolver\Query\Type;
14+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory;
15+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection;
16+
17+
/**
18+
* Adds custom/eav attribute to Catalog product types in the GraphQL config.
19+
*/
20+
class AttributeReader implements ReaderInterface
21+
{
22+
/**
23+
* @var MapperInterface
24+
*/
25+
private $mapper;
26+
27+
/**
28+
* @var Type
29+
*/
30+
private $typeLocator;
31+
32+
/**
33+
* @var CollectionFactory
34+
*/
35+
private $collectionFactory;
36+
37+
/**
38+
* @param MapperInterface $mapper
39+
* @param Type $typeLocator
40+
* @param CollectionFactory $collectionFactory
41+
*/
42+
public function __construct(
43+
MapperInterface $mapper,
44+
Type $typeLocator,
45+
CollectionFactory $collectionFactory
46+
) {
47+
$this->mapper = $mapper;
48+
$this->typeLocator = $typeLocator;
49+
$this->collectionFactory = $collectionFactory;
50+
}
51+
52+
/**
53+
* Read configuration scope
54+
*
55+
* @param string|null $scope
56+
* @return array
57+
* @throws GraphQlInputException
58+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
59+
*/
60+
public function read($scope = null)
61+
{
62+
$targetStructures = $this->mapper->getMappedTypes(\Magento\Catalog\Model\Product::ENTITY);
63+
$config =[];
64+
/** @var Collection $collection */
65+
$collection = $this->collectionFactory->create();
66+
$collection->addFieldToFilter('is_user_defined', '1');
67+
$collection->addFieldToFilter('attribute_code', ['neq' => 'cost']);
68+
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
69+
foreach ($collection as $attribute) {
70+
$attributeCode = $attribute->getAttributeCode();
71+
$locatedType = $this->typeLocator->getType(
72+
$attributeCode,
73+
\Magento\Catalog\Model\Product::ENTITY
74+
) ?: 'String';
75+
$locatedType = $locatedType === TypeProcessor::NORMALIZED_ANY_TYPE ? 'String' : ucfirst($locatedType);
76+
foreach ($targetStructures as $structure) {
77+
$config[$structure]['fields'][$attributeCode] = [
78+
'name' => $attributeCode,
79+
'type' => $locatedType,
80+
'arguments' => []
81+
];
82+
}
83+
}
84+
85+
return $config;
86+
}
87+
}

app/code/Magento/GraphQlCatalog/Model/Resolver/Products.php renamed to app/code/Magento/CatalogGraphQl/Model/Resolver/Products.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\GraphQlCatalog\Model\Resolver;
7+
namespace Magento\CatalogGraphQl\Model\Resolver;
88

9-
use Magento\Framework\Api\Search\SearchCriteriaInterfaceFactory;
109
use Magento\GraphQl\Model\ResolverContextInterface;
1110
use Magento\GraphQl\Model\ResolverInterface;
1211
use Magento\Framework\GraphQl\Argument\SearchCriteria\Builder;
1312
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
14-
use Magento\GraphQl\Model\ContextInterface;
15-
use Magento\GraphQlCatalog\Model\Resolver\Products\Query\Filter;
16-
use Magento\GraphQlCatalog\Model\Resolver\Products\Query\Search;
13+
use Magento\CatalogGraphQl\Model\Resolver\Products\Query\Filter;
14+
use Magento\CatalogGraphQl\Model\Resolver\Products\Query\Search;
1715

1816
/**
1917
* Products field resolver, used for GraphQL request processing.
@@ -63,7 +61,12 @@ public function resolve(array $args, ResolverContextInterface $context)
6361
$searchResult = $this->filterQuery->getResult($searchCriteria);
6462
}
6563

66-
$maxPages = ceil($searchResult->getTotalCount() / $searchCriteria->getPageSize());
64+
//possible division by 0
65+
if ($searchCriteria->getPageSize()) {
66+
$maxPages = ceil($searchResult->getTotalCount() / $searchCriteria->getPageSize());
67+
} else {
68+
$maxPages = 0;
69+
}
6770
if ($searchCriteria->getCurrentPage() > $maxPages && $searchResult->getTotalCount() > 0) {
6871
throw new GraphQlInputException(
6972
__(

app/code/Magento/GraphQlCatalog/Model/Resolver/Products/DataProvider/Product.php renamed to app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\GraphQlCatalog\Model\Resolver\Products\DataProvider;
7+
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider;
88

99
use Magento\Catalog\Api\ProductRepositoryInterface;
1010
use Magento\Catalog\Model\Product\Option;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\GraphQlCatalog\Model\Resolver\Products\DataProvider\Product\Formatter;
7+
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\Formatter;
88

99
use Magento\Catalog\Model\Product;
10-
use Magento\GraphQlCatalog\Model\Resolver\Products\DataProvider\Product\FormatterInterface;
10+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\FormatterInterface;
1111

1212
/**
1313
* Grabs the data from the product
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\GraphQlCatalog\Model\Resolver\Products\DataProvider\Product\Formatter;
7+
namespace Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\Formatter;
88

99
use Magento\Catalog\Model\Product;
10-
use Magento\GraphQlCatalog\Model\Resolver\Products\DataProvider\Product\FormatterInterface;
10+
use Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\FormatterInterface;
1111

1212
/**
1313
* Populates the custom attributes

0 commit comments

Comments
 (0)