Skip to content

Commit 22a9827

Browse files
author
Sergey Shvets
committed
MAGETWO-86239: Customer Address attribute value length is still validated when min/max length fields are not displayed at the backend
1 parent 5ffe84d commit 22a9827

File tree

1 file changed

+16
-2
lines changed
  • app/code/Magento/Customer/Test/Unit/Model/Metadata/Form

1 file changed

+16
-2
lines changed

app/code/Magento/Customer/Test/Unit/Model/Metadata/Form/TextTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
* Copyright © Magento, Inc. All rights reserved.
66
* See COPYING.txt for license details.
77
*/
8+
89
namespace Magento\Customer\Test\Unit\Model\Metadata\Form;
910

11+
use Magento\Customer\Api\Data\ValidationRuleInterface;
1012
use Magento\Customer\Model\Metadata\Form\Text;
1113

1214
class TextTest extends AbstractFormTestCase
@@ -111,7 +113,7 @@ public function validateValueRequiredDataProvider()
111113
*/
112114
public function testValidateValueLength($value, $expected)
113115
{
114-
$minTextLengthRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class)
116+
$minTextLengthRule = $this->getMockBuilder(ValidationRuleInterface::class)
115117
->disableOriginalConstructor()
116118
->setMethods(['getName', 'getValue'])
117119
->getMockForAbstractClass();
@@ -122,7 +124,7 @@ public function testValidateValueLength($value, $expected)
122124
->method('getValue')
123125
->will($this->returnValue(4));
124126

125-
$maxTextLengthRule = $this->getMockBuilder(\Magento\Customer\Api\Data\ValidationRuleInterface::class)
127+
$maxTextLengthRule = $this->getMockBuilder(ValidationRuleInterface::class)
126128
->disableOriginalConstructor()
127129
->setMethods(['getName', 'getValue'])
128130
->getMockForAbstractClass();
@@ -133,7 +135,19 @@ public function testValidateValueLength($value, $expected)
133135
->method('getValue')
134136
->will($this->returnValue(8));
135137

138+
$inputValidationRule = $this->getMockBuilder(ValidationRuleInterface::class)
139+
->disableOriginalConstructor()
140+
->setMethods(['getName', 'getValue'])
141+
->getMockForAbstractClass();
142+
$inputValidationRule->expects($this->any())
143+
->method('getName')
144+
->will($this->returnValue('input_validation'));
145+
$inputValidationRule->expects($this->any())
146+
->method('getValue')
147+
->will($this->returnValue('other'));
148+
136149
$validationRules = [
150+
'input_validation' => $inputValidationRule,
137151
'min_text_length' => $minTextLengthRule,
138152
'max_text_length' => $maxTextLengthRule,
139153
];

0 commit comments

Comments
 (0)