Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product attribute notice translation #10274

Merged
merged 4 commits into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Eav\Model\Config;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\EntityManager\EventManager;
use Magento\Framework\Phrase;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Ui\DataProvider\EavValidationRules;
Expand Down Expand Up @@ -452,12 +453,13 @@ public function testModifyData()
* @param int $productId
* @param bool $productRequired
* @param string $attrValue
* @param string $note
* @param array $expected
* @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::isProductExists
* @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta
* @dataProvider setupAttributeMetaDataProvider
*/
public function testSetupAttributeMetaDefaultAttribute($productId, $productRequired, $attrValue, $expected)
public function testSetupAttributeMetaDefaultAttribute($productId, $productRequired, $attrValue, $note, $expected)
{
$configPath = 'arguments/data/config';
$groupCode = 'product-details';
Expand All @@ -483,6 +485,10 @@ public function testSetupAttributeMetaDefaultAttribute($productId, $productRequi
->method('getValue')
->willReturn('value');

$this->productAttributeMock->expects($this->any())
->method('getNote')
->willReturn($note);

$attributeMock = $this->getMockBuilder(AttributeInterface::class)
->disableOriginalConstructor()
->getMock();
Expand Down Expand Up @@ -527,82 +533,147 @@ public function testSetupAttributeMetaDefaultAttribute($productId, $productRequi
public function setupAttributeMetaDataProvider()
{
return [
'default_null_prod_not_new_and_required' => [
'productId' => 1,
'productRequired' => true,
'attrValue' => 'val',
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => true,
'notice' => null,
'default' => null,
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
],
'default_null_prod_not_new_and_not_required' => [
'productId' => 1,
'productRequired' => false,
'attrValue' => 'val',
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => false,
'notice' => null,
'default' => null,
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
],
'default_null_prod_new_and_not_required' => [
'productId' => null,
'productRequired' => false,
'attrValue' => null,
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => false,
'notice' => null,
'default' => 'required_value',
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
'default_null_prod_not_new_and_required' => $this->defaultNullProdNotNewAndRequired(),
'default_null_prod_not_new_and_not_required' => $this->defaultNullProdNotNewAndNotRequired(),
'default_null_prod_new_and_not_required' => $this->defaultNullProdNewAndNotRequired(),
'default_null_prod_new_and_required' => $this->defaultNullProdNewAndRequired(),
'default_null_prod_new_and_required_and_filled_notice' =>
$this->defaultNullProdNewAndRequiredAndFilledNotice()
];
}

/**
* @return array
*/
private function defaultNullProdNotNewAndRequired()
{
return [
'productId' => 1,
'productRequired' => true,
'attrValue' => 'val',
'note' => null,
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => true,
'notice' => null,
'default' => null,
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
];
}

/**
* @return array
*/
private function defaultNullProdNotNewAndNotRequired()
{
return [
'productId' => 1,
'productRequired' => false,
'attrValue' => 'val',
'note' => null,
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => false,
'notice' => null,
'default' => null,
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
];
}

/**
* @return array
*/
private function defaultNullProdNewAndNotRequired()
{
return [
'productId' => null,
'productRequired' => false,
'attrValue' => null,
'note' => null,
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => false,
'notice' => null,
'default' => 'required_value',
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
];
}

/**
* @return array
*/
private function defaultNullProdNewAndRequired()
{
return [
'productId' => null,
'productRequired' => false,
'attrValue' => null,
'note' => null,
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => false,
'notice' => null,
'default' => 'required_value',
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
];
}

/**
* @return array
*/
private function defaultNullProdNewAndRequiredAndFilledNotice()
{
return [
'productId' => null,
'productRequired' => false,
'attrValue' => null,
'note' => 'example notice',
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => false,
'notice' => __('example notice'),
'default' => 'required_value',
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
'default_null_prod_new_and_required' => [
'productId' => null,
'productRequired' => false,
'attrValue' => null,
'expected' => [
'dataType' => null,
'formElement' => null,
'visible' => null,
'required' => false,
'notice' => null,
'default' => 'required_value',
'label' => null,
'code' => 'code',
'source' => 'product-details',
'scopeLabel' => '',
'globalScope' => false,
'sortOrder' => 0
],
]
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC
'formElement' => $this->getFormElementsMapValue($attribute->getFrontendInput()),
'visible' => $attribute->getIsVisible(),
'required' => $attribute->getIsRequired(),
'notice' => $attribute->getNote(),
'notice' => $attribute->getNote() === null ? null : __($attribute->getNote()),
'default' => (!$this->isProductExists()) ? $attribute->getDefaultValue() : null,
'label' => $attribute->getDefaultFrontendLabel(),
'code' => $attribute->getAttributeCode(),
Expand Down