Skip to content

Commit 0c59f9d

Browse files
committed
updated test
1 parent fd8f1bb commit 0c59f9d

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

app/code/core/Mage/Customer/Model/Customer.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,9 +1729,7 @@ public function getMinPasswordLength()
17291729
*/
17301730
public function shouldValidateDob($entityType): bool
17311731
{
1732-
/** @var Mage_Customer_Model_Attribute $model */
1733-
$model = Mage::getModel('customer/attribute');
1734-
$attribute = $model->loadByCode($entityType, 'dob');
1732+
$attribute = $this->getCustomerAttributeModel()->loadByCode($entityType, 'dob');
17351733
return $attribute->getIsRequired();
17361734
}
17371735

@@ -1740,20 +1738,23 @@ public function shouldValidateDob($entityType): bool
17401738
*/
17411739
public function shouldValidateGender($entityType): bool
17421740
{
1743-
/** @var Mage_Customer_Model_Attribute $model */
1744-
$model = Mage::getModel('customer/attribute');
1745-
$attribute = $model->loadByCode($entityType, 'gender');
1741+
$attribute = $this->getCustomerAttributeModel()->loadByCode($entityType, 'gender');
17461742
return $attribute->getIsRequired();
17471743
}
17481744

17491745
/**
17501746
* @throws Mage_Core_Exception
17511747
*/
17521748
public function shouldValidateTaxvat($entityType): bool
1749+
{
1750+
$attribute = $this->getCustomerAttributeModel()->loadByCode($entityType, 'taxvat');
1751+
return $attribute->getIsRequired();
1752+
}
1753+
1754+
public function getCustomerAttributeModel(): Mage_Customer_Model_Attribute
17531755
{
17541756
/** @var Mage_Customer_Model_Attribute $model */
17551757
$model = Mage::getModel('customer/attribute');
1756-
$attribute = $model->loadByCode($entityType, 'taxvat');
1757-
return $attribute->getIsRequired();
1758+
return $model->getIsRequired();
17581759
}
17591760
}

tests/unit/Mage/Admin/Model/BlockTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function testValidate($expectedResult, array $methods): void
5656

5757
public function provideValidateAdminBlockData(): Generator
5858
{
59+
$errorIncorrectBlockName = 'Block Name is incorrect.';
60+
5961
yield 'valid' => [
6062
true,
6163
[
@@ -64,9 +66,7 @@ public function provideValidateAdminBlockData(): Generator
6466
],
6567
];
6668
yield 'invalid' => [
67-
[
68-
0 => 'Block Name is incorrect.',
69-
],
69+
[$errorIncorrectBlockName],
7070
[
7171
'getBlockName' => 'Test_Block',
7272
'getIsAllowed' => '1',
@@ -83,18 +83,14 @@ public function provideValidateAdminBlockData(): Generator
8383
],
8484
];
8585
yield 'errors: invalid char blockname' => [
86-
[
87-
0 => 'Block Name is incorrect.',
88-
],
86+
[$errorIncorrectBlockName],
8987
[
9088
'getBlockName' => '~',
9189
'getIsAllowed' => '0',
9290
],
9391
];
9492
yield 'errors: invalid blockname' => [
95-
[
96-
0 => 'Block Name is incorrect.',
97-
],
93+
[$errorIncorrectBlockName],
9894
[
9995
'getBlockName' => 'test',
10096
'getIsAllowed' => '0',

0 commit comments

Comments
 (0)