Skip to content

Commit 5acd1b3

Browse files
committed
38325 tests fixes
1 parent 42e5fd2 commit 5acd1b3

File tree

4 files changed

+65
-62
lines changed

4 files changed

+65
-62
lines changed

app/code/Magento/Customer/Block/Widget/City.php

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

7+
declare(strict_types=1);
8+
79
namespace Magento\Customer\Block\Widget;
810

911
use Magento\Customer\Api\AddressMetadataInterface;
1012
use Magento\Customer\Api\CustomerMetadataInterface;
13+
use Magento\Customer\Api\Data\AttributeMetadataInterface;
1114
use Magento\Customer\Api\Data\CustomerInterface;
1215
use Magento\Customer\Helper\Address as AddressHelper;
1316
use Magento\Customer\Model\Options;
1417
use Magento\Framework\Exception\LocalizedException;
18+
use Magento\Framework\Exception\NoSuchEntityException;
1519
use Magento\Framework\View\Element\Template\Context;
1620

1721
/**
@@ -28,17 +32,17 @@ class City extends AbstractWidget
2832
/**
2933
* the attribute code
3034
*/
31-
const ATTRIBUTE_CODE = 'city';
35+
public const ATTRIBUTE_CODE = 'city';
3236

3337
/**
3438
* @var AddressMetadataInterface
3539
*/
36-
protected $addressMetadata;
40+
private $addressMetadata;
3741

3842
/**
3943
* @var Options
4044
*/
41-
protected $options;
45+
private $options;
4246

4347
/**
4448
* @param Context $context
@@ -63,7 +67,7 @@ public function __construct(
6367
}
6468

6569
/**
66-
* @return void
70+
* @inheritdoc
6771
*/
6872
public function _construct()
6973
{
@@ -73,40 +77,35 @@ public function _construct()
7377
$this->setTemplate('Magento_Customer::widget/city.phtml');
7478
}
7579

76-
/**
77-
* Can show config value
78-
*
79-
* @param string $key
80-
*
81-
* @return bool
82-
*/
83-
protected function _showConfig($key)
84-
{
85-
return (bool)$this->getConfig($key);
86-
}
87-
8880
/**
8981
* Can show prefix
9082
*
9183
* @return bool
9284
*/
9385
public function showCity()
9486
{
95-
return $this->_isAttributeVisible(self::ATTRIBUTE_CODE);
87+
return $this->isAttributeVisible(self::ATTRIBUTE_CODE);
9688
}
9789

9890
/**
99-
* @inheritdoc
91+
* Retrieve customer attribute instance
92+
*
93+
* @param string $attributeCode
94+
*
95+
* @return AttributeMetadataInterface|null
96+
* @throws LocalizedException
10097
*/
98+
//@codingStandardsIgnoreStart
10199
protected function _getAttribute($attributeCode)
100+
//@codingStandardsIgnoreEnd
102101
{
103102
if ($this->getForceUseCustomerAttributes() || $this->getObject() instanceof CustomerInterface) {
104103
return parent::_getAttribute($attributeCode);
105104
}
106105

107106
try {
108107
$attribute = $this->addressMetadata->getAttributeMetadata($attributeCode);
109-
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
108+
} catch (NoSuchEntityException $e) {
110109
return null;
111110
}
112111

@@ -147,11 +146,13 @@ public function getAttributeValidationClass(string $attributeCode)
147146
}
148147

149148
/**
149+
* Checks is attribute visible
150+
*
150151
* @param string $attributeCode
151152
*
152153
* @return bool
153154
*/
154-
private function _isAttributeVisible(string $attributeCode)
155+
private function isAttributeVisible(string $attributeCode)
155156
{
156157
$attributeMetadata = $this->_getAttribute($attributeCode);
157158
return $attributeMetadata ? (bool)$attributeMetadata->isVisible() : false;

app/code/Magento/Customer/Model/Address/Validator/General.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ private function checkRequiredFields(AbstractAddress $address)
8484
* @param AbstractAddress $address
8585
* @return array
8686
* @throws LocalizedException|ValidateException
87+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
88+
* @SuppressWarnings(PHPMD.NPathComplexity)
8789
*/
8890
private function checkOptionalFields(AbstractAddress $address)
8991
{
@@ -108,8 +110,8 @@ private function checkOptionalFields(AbstractAddress $address)
108110
}
109111

110112
if ($this->isCityRequired()
111-
&& !ValidatorChain::is($address->getCity(), NotEmpty::class))
112-
{
113+
&& !ValidatorChain::is($address->getCity(), NotEmpty::class)
114+
) {
113115
$errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'city']);
114116
}
115117

app/code/Magento/Customer/etc/config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<telephone_show>req</telephone_show>
6060
<company_show>opt</company_show>
6161
<fax_show/>
62-
<city_show>opt</city_show>
62+
<city_show>req</city_show>
6363
</address>
6464
<startup>
6565
<redirect_dashboard>0</redirect_dashboard>

app/code/Magento/Customer/view/frontend/templates/address/edit.phtml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ use Magento\Framework\View\Helper\SecureHtmlRenderer;
2222
$viewModel = $block->getViewModel();
2323
$regionProvider = $block->getRegionProvider();
2424
?>
25-
<?php $_company = $block->getLayout()->createBlock(Company::class) ?>
26-
<?php $_telephone = $block->getLayout()->createBlock(Telephone::class) ?>
27-
<?php $_fax = $block->getLayout()->createBlock(Fax::class) ?>
28-
<?php $_country_id = $block->getAttributeData()->getFrontendLabel('country_id'); ?>
29-
<?php $_street = $block->getAttributeData()->getFrontendLabel('street'); ?>
30-
<?php $_city = $block->getLayout()->createBlock(City::class); ?>
31-
<?php $_region = $block->getAttributeData()->getFrontendLabel('region'); ?>
32-
<?php $_selectRegion = 'Please select a region, state or province.'; ?>
33-
<?php $_displayAll = $block->getConfig('general/region/display_all'); ?>
25+
<?php $company = $block->getLayout()->createBlock(Company::class) ?>
26+
<?php $telephone = $block->getLayout()->createBlock(Telephone::class) ?>
27+
<?php $fax = $block->getLayout()->createBlock(Fax::class) ?>
28+
<?php $country_id = $block->getAttributeData()->getFrontendLabel('country_id'); ?>
29+
<?php $street = $block->getAttributeData()->getFrontendLabel('street'); ?>
30+
<?php $city = $block->getLayout()->createBlock(City::class); ?>
31+
<?php $region = $block->getAttributeData()->getFrontendLabel('region'); ?>
32+
<?php $selectRegion = 'Please select a region, state or province.'; ?>
33+
<?php $displayAll = $block->getConfig('general/region/display_all'); ?>
3434

35-
<?php $_vatidValidationClass = $viewModel->addressGetAttributeValidationClass('vat_id'); ?>
36-
<?php $_cityValidationClass = $viewModel->addressGetAttributeValidationClass('city'); ?>
37-
<?php $_postcodeValidationClass_value = $viewModel->addressGetAttributeValidationClass('postcode'); ?>
38-
<?php $_postcodeValidationClass = $_postcodeValidationClass_value; ?>
39-
<?php $_streetValidationClass = $viewModel->addressGetAttributeValidationClass('street'); ?>
40-
<?php $_streetValidationClassNotRequired = $_streetValidationClass !== null ?
41-
trim(str_replace('required-entry', '', $_streetValidationClass)) : ''; ?>
42-
<?php $_regionValidationClass = $viewModel->addressGetAttributeValidationClass('region'); ?>
35+
<?php $vatIdValidationClass = $viewModel->addressGetAttributeValidationClass('vat_id'); ?>
36+
<?php $cityValidationClass = $viewModel->addressGetAttributeValidationClass('city'); ?>
37+
<?php $postcodeValidationClass_value = $viewModel->addressGetAttributeValidationClass('postcode'); ?>
38+
<?php $postcodeValidationClass = $postcodeValidationClass_value; ?>
39+
<?php $streetValidationClass = $viewModel->addressGetAttributeValidationClass('street'); ?>
40+
<?php $streetValidationClassNotRequired = $streetValidationClass !== null ?
41+
trim(str_replace('required-entry', '', $streetValidationClass)) : ''; ?>
42+
<?php $regionValidationClass = $viewModel->addressGetAttributeValidationClass('region'); ?>
4343
<form class="form-address-edit"
4444
action="<?= $escaper->escapeUrl($block->getSaveUrl()) ?>"
4545
method="post"
@@ -53,23 +53,23 @@ $regionProvider = $block->getRegionProvider();
5353
<input type="hidden" name="error_url" value="<?= $escaper->escapeUrl($block->getErrorUrl()) ?>">
5454
<?= $block->getNameBlockHtml() ?>
5555

56-
<?php if ($_company->isEnabled()): ?>
57-
<?= $_company->setCompany($block->getAddress()->getCompany())->toHtml() ?>
56+
<?php if ($company->isEnabled()): ?>
57+
<?= $company->setCompany($block->getAddress()->getCompany())->toHtml() ?>
5858
<?php endif ?>
5959

60-
<?php if ($_telephone->isEnabled()): ?>
61-
<?= $_telephone->setTelephone($block->getAddress()->getTelephone())->toHtml() ?>
60+
<?php if ($telephone->isEnabled()): ?>
61+
<?= $telephone->setTelephone($block->getAddress()->getTelephone())->toHtml() ?>
6262
<?php endif ?>
6363

64-
<?php if ($_fax->isEnabled()): ?>
65-
<?= $_fax->setFax($block->getAddress()->getFax())->toHtml() ?>
64+
<?php if ($fax->isEnabled()): ?>
65+
<?= $fax->setFax($block->getAddress()->getFax())->toHtml() ?>
6666
<?php endif ?>
6767

6868
</fieldset>
6969
<fieldset class="fieldset">
7070
<legend class="legend"><span><?= $escaper->escapeHtml(__('Address')) ?></span></legend><br>
7171
<div class="field street required">
72-
<label for="street_1" class="label"><span><?= /* @noEscape */ $_street ?></span></label>
72+
<label for="street_1" class="label"><span><?= /* @noEscape */ $street ?></span></label>
7373
<div class="control">
7474
<div class="field primary">
7575
<label for="street_1" class="label">
@@ -81,9 +81,9 @@ $regionProvider = $block->getRegionProvider();
8181
<input type="text"
8282
name="street[0]"
8383
value="<?= $escaper->escapeHtmlAttr($block->getStreetLine(1)) ?>"
84-
title="<?= /* @noEscape */ $_street ?>"
84+
title="<?= /* @noEscape */ $street ?>"
8585
id="street_1"
86-
class="input-text <?= $escaper->escapeHtmlAttr($_streetValidationClass) ?>"/>
86+
class="input-text <?= $escaper->escapeHtmlAttr($streetValidationClass) ?>"/>
8787
<div class="nested">
8888
<?php for ($_i = 1, $_n = $viewModel->addressGetStreetLines(); $_i < $_n; $_i++): ?>
8989
<div class="field additional">
@@ -96,7 +96,7 @@ $regionProvider = $block->getRegionProvider();
9696
title="<?= $escaper->escapeHtmlAttr(__('Street Address %1', $_i + 1)) ?>"
9797
id="street_<?= /* @noEscape */ $_i + 1 ?>"
9898
class="input-text
99-
<?= $escaper->escapeHtmlAttr($_streetValidationClassNotRequired) ?>">
99+
<?= $escaper->escapeHtmlAttr($streetValidationClassNotRequired) ?>">
100100
</div>
101101
</div>
102102
<?php endfor; ?>
@@ -114,7 +114,7 @@ $regionProvider = $block->getRegionProvider();
114114
name="vat_id"
115115
value="<?= $escaper->escapeHtmlAttr($block->getAddress()->getVatId()) ?>"
116116
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('vat_id') ?>"
117-
class="input-text <?= $escaper->escapeHtmlAttr($_vatidValidationClass) ?>"
117+
class="input-text <?= $escaper->escapeHtmlAttr($vatIdValidationClass) ?>"
118118
id="vat_id">
119119
</div>
120120
</div>
@@ -129,28 +129,28 @@ $regionProvider = $block->getRegionProvider();
129129
</div>
130130
<div class="field region required">
131131
<label class="label" for="region_id">
132-
<span><?= /* @noEscape */ $_region ?></span>
132+
<span><?= /* @noEscape */ $region ?></span>
133133
</label>
134134
<div class="control">
135135
<select id="region_id" name="region_id"
136-
title="<?= /* @noEscape */ $_region ?>"
136+
title="<?= /* @noEscape */ $region ?>"
137137
class="validate-select region_id"
138-
<?= /* @noEscape */ !$_displayAll ? ' disabled="disabled"' : '' ?>>
139-
<option value=""><?= $escaper->escapeHtml(__($_selectRegion)) ?></option>
138+
<?= /* @noEscape */ !$displayAll ? ' disabled="disabled"' : '' ?>>
139+
<option value=""><?= $escaper->escapeHtml(__($selectRegion)) ?></option>
140140
</select>
141141
<input type="text"
142142
id="region"
143143
name="region"
144144
value="<?= $escaper->escapeHtmlAttr($block->getRegion()) ?>"
145-
title="<?= /* @noEscape */ $_region ?>"
145+
title="<?= /* @noEscape */ $region ?>"
146146
class="input-text validate-not-number-first
147-
<?= $escaper->escapeHtmlAttr($_regionValidationClass) ?>"
148-
<?= !$_displayAll ? ' disabled="disabled"' : '' ?>/>
147+
<?= $escaper->escapeHtmlAttr($regionValidationClass) ?>"
148+
<?= !$displayAll ? ' disabled="disabled"' : '' ?>/>
149149
</div>
150150
</div>
151151

152-
<?php if ($_city->isEnabled()): ?>
153-
<?= $_city->setCity($block->getAddress()->getCity())->toHtml() ?>
152+
<?php if ($city->isEnabled()): ?>
153+
<?= $city->setCity($block->getAddress()->getCity())->toHtml() ?>
154154
<?php endif ?>
155155

156156
<div class="field zip required">
@@ -164,7 +164,7 @@ $regionProvider = $block->getRegionProvider();
164164
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?>"
165165
id="zip"
166166
class="input-text validate-zip-international
167-
<?= $escaper->escapeHtmlAttr($_postcodeValidationClass) ?>">
167+
<?= $escaper->escapeHtmlAttr($postcodeValidationClass) ?>">
168168
<div role="alert" class="message warning">
169169
<span></span>
170170
</div>
@@ -228,7 +228,7 @@ $regionProvider = $block->getRegionProvider();
228228
},
229229
"#country": {
230230
"directoryRegionUpdater": {
231-
"optionalRegionAllowed": <?= /* @noEscape */ $_displayAll ? 'true' : 'false' ?>,
231+
"optionalRegionAllowed": <?= /* @noEscape */ $displayAll ? 'true' : 'false' ?>,
232232
"regionListId": "#region_id",
233233
"regionInputId": "#region",
234234
"postcodeId": "#zip",

0 commit comments

Comments
 (0)