Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.3-develop' into graphQl-309-ch…
Browse files Browse the repository at this point in the history
…eckout-agreement-coverage
  • Loading branch information
naydav committed May 8, 2019
2 parents c3040e6 + c56341c commit c1c1dc0
Show file tree
Hide file tree
Showing 45 changed files with 616 additions and 321 deletions.
9 changes: 3 additions & 6 deletions app/code/Magento/Catalog/Block/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ public function getAddToCartUrl($product, $additional = [])
}

/**
* Get JSON encoded configuration array which can be used for JS dynamic
* price calculation depending on product options
* Get JSON encoded configuration which can be used for JS dynamic price calculation depending on product options
*
* @return string
*/
Expand Down Expand Up @@ -262,6 +261,7 @@ public function isStartCustomization()

/**
* Get default qty - either as preconfigured, or as 1.
*
* Also restricts it by minimal qty.
*
* @param null|\Magento\Catalog\Model\Product $product
Expand Down Expand Up @@ -323,10 +323,7 @@ public function getQuantityValidators()
public function getIdentities()
{
$identities = $this->getProduct()->getIdentities();
$category = $this->_coreRegistry->registry('current_category');
if ($category) {
$identities[] = Category::CACHE_TAG . '_' . $category->getId();
}

return $identities;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Magento\Framework\DB\Select;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\Indexer\DimensionFactory;
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;
use Magento\Store\Model\Indexer\WebsiteDimensionProvider;
use Magento\Store\Model\Store;

Expand Down
19 changes: 13 additions & 6 deletions app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

namespace Magento\Catalog\Test\Unit\Block\Product;

/**
* Class ViewTest
*/
class ViewTest extends \PHPUnit\Framework\TestCase
{
/**
Expand All @@ -25,6 +28,9 @@ class ViewTest extends \PHPUnit\Framework\TestCase
*/
protected $registryMock;

/**
* @inheritDoc
*/
protected function setUp()
{
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand All @@ -36,6 +42,9 @@ protected function setUp()
);
}

/**
* @return void
*/
public function testShouldRenderQuantity()
{
$productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
Expand All @@ -61,28 +70,26 @@ public function testShouldRenderQuantity()
$this->assertEquals(false, $this->view->shouldRenderQuantity());
}

/**
* @return void
*/
public function testGetIdentities()
{
$productTags = ['cat_p_1'];
$product = $this->createMock(\Magento\Catalog\Model\Product::class);
$category = $this->createMock(\Magento\Catalog\Model\Category::class);

$product->expects($this->once())
->method('getIdentities')
->will($this->returnValue($productTags));
$category->expects($this->once())
->method('getId')
->will($this->returnValue(1));
$this->registryMock->expects($this->any())
->method('registry')
->will(
$this->returnValueMap(
[
['product', $product],
['current_category', $category],
]
)
);
$this->assertEquals(['cat_p_1', 'cat_c_1'], $this->view->getIdentities());
$this->assertEquals($productTags, $this->view->getIdentities());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
use Magento\Catalog\Api\Data\ProductRenderInterface;

/**
* Composite, which holds collectors, that collect enought information for
* product render
* Composite, which holds collectors, that collect enough information for product render
*/
class ProductRenderCollectorComposite implements ProductRenderCollectorInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
</arguments>
<waitForLoadingMaskToDisappear stepKey="waitForMaskToDisappear" after="assertSubtotal"/>
<waitForElementVisible selector="{{CheckoutCartSummarySection.shipping}}" time="60" stepKey="waitForElementToBeVisible" after="waitForMaskToDisappear"/>
<!-- Shipping can take a long time to change in builds, can't rely on an explicit wait-->
<wait time="30" stepKey="waitForShippingDetailsToLoad" after="waitForElementToBeVisible"/>
<see userInput="{{shipping}}" selector="{{CheckoutCartSummarySection.shipping}}" stepKey="assertShipping" after="waitForShippingDetailsToLoad" />
<waitForText userInput="{{shipping}}" selector="{{CheckoutCartSummarySection.shipping}}" time="60" stepKey="assertShipping" after="waitForElementToBeVisible"/>
</actionGroup>
</actionGroups>
4 changes: 2 additions & 2 deletions app/code/Magento/Customer/Model/Address/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

/**
* Dataprovider of customer addresses for customer address grid.
*
* @property \Magento\Customer\Model\ResourceModel\Address\Collection $collection
*/
class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
Expand Down Expand Up @@ -222,8 +223,7 @@ private function getAttributesMeta(Type $entityType): array
$meta[$attribute->getAttributeCode()] = $this->attributeMetadataResolver->getAttributesMeta(
$attribute,
$entityType,
$this->allowToShowHiddenAttributes,
$this->getRequestFieldName()
$this->allowToShowHiddenAttributes
);
}
$this->attributeMetadataResolver->processWebsiteMeta($meta);
Expand Down
43 changes: 4 additions & 39 deletions app/code/Magento/Customer/Model/AttributeMetadataResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,13 @@ public function __construct(
* @param AbstractAttribute $attribute
* @param Type $entityType
* @param bool $allowToShowHiddenAttributes
* @param string $requestFieldName
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getAttributesMeta(
AbstractAttribute $attribute,
Type $entityType,
bool $allowToShowHiddenAttributes,
string $requestFieldName
bool $allowToShowHiddenAttributes
): array {
$meta = $this->modifyBooleanAttributeMeta($attribute);
// use getDataUsingMethod, since some getters are defined and apply additional processing of returning value
Expand Down Expand Up @@ -138,7 +136,6 @@ public function getAttributesMeta(
$meta['arguments']['data']['config']['componentType'] = Field::NAME;
$meta['arguments']['data']['config']['visible'] = $this->canShowAttribute(
$attribute,
$requestFieldName,
$allowToShowHiddenAttributes
);

Expand All @@ -155,48 +152,16 @@ public function getAttributesMeta(
* Detect can we show attribute on specific form or not
*
* @param AbstractAttribute $customerAttribute
* @param string $requestFieldName
* @param bool $allowToShowHiddenAttributes
* @return bool
*/
private function canShowAttribute(
AbstractAttribute $customerAttribute,
string $requestFieldName,
bool $allowToShowHiddenAttributes
) {
$userDefined = (bool)$customerAttribute->getIsUserDefined();
if (!$userDefined) {
return $customerAttribute->getIsVisible();
}

$canShowOnForm = $this->canShowAttributeInForm($customerAttribute, $requestFieldName);

return ($allowToShowHiddenAttributes && $canShowOnForm) ||
(!$allowToShowHiddenAttributes && $canShowOnForm && $customerAttribute->getIsVisible());
}

/**
* Check whether the specific attribute can be shown in form: customer registration, customer edit, etc...
*
* @param AbstractAttribute $customerAttribute
* @param string $requestFieldName
* @return bool
*/
private function canShowAttributeInForm(AbstractAttribute $customerAttribute, string $requestFieldName): bool
{
$isRegistration = $this->context->getRequestParam($requestFieldName) === null;

if ($customerAttribute->getEntityType()->getEntityTypeCode() === 'customer') {
return \is_array($customerAttribute->getUsedInForms()) &&
(
(\in_array('customer_account_create', $customerAttribute->getUsedInForms(), true)
&& $isRegistration) ||
(\in_array('customer_account_edit', $customerAttribute->getUsedInForms(), true)
&& !$isRegistration)
);
}
return \is_array($customerAttribute->getUsedInForms()) &&
\in_array('customer_address_edit', $customerAttribute->getUsedInForms(), true);
return $allowToShowHiddenAttributes && (bool) $customerAttribute->getIsUserDefined()
? true
: (bool) $customerAttribute->getIsVisible();
}

/**
Expand Down
36 changes: 4 additions & 32 deletions app/code/Magento/Customer/Model/Customer/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,45 +307,17 @@ protected function getAttributesMeta(Type $entityType)
return $meta;
}

/**
* Check whether the specific attribute can be shown in form: customer registration, customer edit, etc...
*
* @param Attribute $customerAttribute
* @return bool
*/
private function canShowAttributeInForm(AbstractAttribute $customerAttribute)
{
$isRegistration = $this->context->getRequestParam($this->getRequestFieldName()) === null;

if ($customerAttribute->getEntityType()->getEntityTypeCode() === 'customer') {
return is_array($customerAttribute->getUsedInForms()) &&
(
(in_array('customer_account_create', $customerAttribute->getUsedInForms()) && $isRegistration) ||
(in_array('customer_account_edit', $customerAttribute->getUsedInForms()) && !$isRegistration)
);
} else {
return is_array($customerAttribute->getUsedInForms()) &&
in_array('customer_address_edit', $customerAttribute->getUsedInForms());
}
}

/**
* Detect can we show attribute on specific form or not
*
* @param Attribute $customerAttribute
* @return bool
*/
private function canShowAttribute(AbstractAttribute $customerAttribute)
private function canShowAttribute(AbstractAttribute $customerAttribute): bool
{
$userDefined = (bool) $customerAttribute->getIsUserDefined();
if (!$userDefined) {
return $customerAttribute->getIsVisible();
}

$canShowOnForm = $this->canShowAttributeInForm($customerAttribute);

return ($this->allowToShowHiddenAttributes && $canShowOnForm) ||
(!$this->allowToShowHiddenAttributes && $canShowOnForm && $customerAttribute->getIsVisible());
return $this->allowToShowHiddenAttributes && (bool) $customerAttribute->getIsUserDefined()
? true
: (bool) $customerAttribute->getIsVisible();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ private function getAttributesMeta(Type $entityType): array
$meta[$attribute->getAttributeCode()] = $this->attributeMetadataResolver->getAttributesMeta(
$attribute,
$entityType,
$this->allowToShowHiddenAttributes,
$this->getRequestFieldName()
$this->allowToShowHiddenAttributes
);
}
$this->attributeMetadataResolver->processWebsiteMeta($meta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1087,16 +1087,15 @@ public function testGetDataWithVisibleAttributesWithAccountEdit()

$meta = $dataProvider->getMeta();
$this->assertNotEmpty($meta);
$this->assertEquals($this->getExpectationForVisibleAttributes(false), $meta);
$this->assertEquals($this->getExpectationForVisibleAttributes(), $meta);
}

/**
* Retrieve all customer variations of attributes with all variations of visibility
*
* @param bool $isRegistration
* @return array
*/
private function getCustomerAttributeExpectations($isRegistration)
private function getCustomerAttributeExpectations()
{
return [
self::ATTRIBUTE_CODE . "_1" => [
Expand All @@ -1106,7 +1105,7 @@ private function getCustomerAttributeExpectations($isRegistration)
'dataType' => 'frontend_input',
'formElement' => 'frontend_input',
'options' => 'test-options',
'visible' => !$isRegistration,
'visible' => true,
'required' => 'is_required',
'label' => __('frontend_label'),
'sortOrder' => 'sort_order',
Expand Down Expand Up @@ -1143,7 +1142,7 @@ private function getCustomerAttributeExpectations($isRegistration)
'config' => [
'dataType' => 'frontend_input',
'formElement' => 'frontend_input',
'visible' => $isRegistration,
'visible' => true,
'required' => 'is_required',
'label' => __('frontend_label'),
'sortOrder' => 'sort_order',
Expand All @@ -1166,7 +1165,7 @@ private function getCustomerAttributeExpectations($isRegistration)
'config' => [
'dataType' => 'frontend_input',
'formElement' => 'frontend_input',
'visible' => $isRegistration,
'visible' => true,
'required' => 'is_required',
'label' => __('frontend_label'),
'sortOrder' => 'sort_order',
Expand All @@ -1189,14 +1188,13 @@ private function getCustomerAttributeExpectations($isRegistration)
/**
* Retrieve all variations of attributes with all variations of visibility
*
* @param bool $isRegistration
* @return array
*/
private function getExpectationForVisibleAttributes($isRegistration = true)
private function getExpectationForVisibleAttributes()
{
return [
'customer' => [
'children' => $this->getCustomerAttributeExpectations($isRegistration),
'children' => $this->getCustomerAttributeExpectations(),
],
'address' => [
'children' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
*/
namespace Magento\Eav\Test\Unit\Model\Entity\Collection;

use Magento\Framework\Data\Collection\Db\FetchStrategyInterface;
use Magento\Framework\Model\ResourceModel\ResourceModelPoolInterface;

/**
* AbstractCollection test
*
Expand All @@ -31,7 +28,7 @@ class AbstractCollectionTest extends \PHPUnit\Framework\TestCase
protected $loggerMock;

/**
* @var FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Data\Collection\Db\FetchStrategyInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $fetchStrategyMock;

Expand Down Expand Up @@ -61,7 +58,7 @@ class AbstractCollectionTest extends \PHPUnit\Framework\TestCase
protected $resourceHelperMock;

/**
* @var ResourceModelPoolInterface|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Validator\UniversalFactory|\PHPUnit_Framework_MockObject_MockObject
*/
protected $validatorFactoryMock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if ($block->getIsShipping()):
require(["Magento_Sales/order/create/form"], function(){

order.shippingAddressContainer = '<?= /* @escapeNotVerified */ $_fieldsContainerId ?>';
order.setAddresses(<?= /* @escapeNotVerified */ $customerAddressFormatter->getAddressesJson($addressArray) ?>);
order.setAddresses(<?= /* @escapeVerfied */ $block->getAddressCollectionJson() ?>);

});
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
.store-scope {
.admin__legend {
.admin__field-tooltip {
margin-left: -@indent__base;
margin-left: 0;
margin-top: .5rem;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@
font-size: 14px;
font-weight: 600;
line-height: 3.2rem;
padding: 0 30px 0 0;
padding: 0 30px 0 30px;
white-space: nowrap;
word-wrap: break-word;

Expand Down
Loading

0 comments on commit c1c1dc0

Please sign in to comment.