Skip to content

Commit ad19915

Browse files
committed
Merge remote-tracking branch 'trigger/34644' into ph-delivery
2 parents 89783a8 + 6f2a589 commit ad19915

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

app/code/Magento/Config/Model/Config/Source/Date/Short.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@
1212
class Short implements \Magento\Framework\Option\ArrayInterface
1313
{
1414
/**
15+
* Method return array of date options.
16+
*
1517
* @return array
1618
*/
1719
public function toOptionArray()
1820
{
1921
$arr = [];
22+
$dateTime = new \DateTime();
2023
$arr[] = ['label' => '', 'value' => ''];
21-
$arr[] = ['label' => strftime('MM/DD/YY (%m/%d/%y)'), 'value' => '%m/%d/%y'];
22-
$arr[] = ['label' => strftime('MM/DD/YYYY (%m/%d/%Y)'), 'value' => '%m/%d/%Y'];
23-
$arr[] = ['label' => strftime('DD/MM/YY (%d/%m/%y)'), 'value' => '%d/%m/%y'];
24-
$arr[] = ['label' => strftime('DD/MM/YYYY (%d/%m/%Y)'), 'value' => '%d/%m/%Y'];
24+
$arr[] = ['label' => 'MM/DD/YY (' . $dateTime->format('m/d/y') . ')', 'value' => '%m/%d/%y'];
25+
$arr[] = ['label' => 'MM/DD/YYYY (' . $dateTime->format('m/d/Y') . ')', 'value' => '%m/%d/%Y'];
26+
$arr[] = ['label' => 'DD/MM/YY (' . $dateTime->format('d/m/y') . ')', 'value' => '%d/%m/%y'];
27+
$arr[] = ['label' => 'DD/MM/YYYY (' . $dateTime->format('d/m/Y') . ')', 'value' => '%d/%m/%Y'];
2528
return $arr;
2629
}
2730
}

app/code/Magento/Sales/Model/Order/Address/Validator.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
use Magento\Directory\Model\CountryFactory;
1111
use Magento\Eav\Model\Config as EavConfig;
1212
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\Exception\LocalizedException;
1314
use Magento\Sales\Model\Order\Address;
1415

1516
/**
16-
* Class Validator
17+
* Class for validating customer address.
1718
*/
1819
class Validator
1920
{
@@ -66,7 +67,7 @@ public function __construct(
6667
/**
6768
* Validate address.
6869
*
69-
* @param \Magento\Sales\Model\Order\Address $address
70+
* @param Address $address
7071
* @return array
7172
*/
7273
public function validate(Address $address)
@@ -93,7 +94,7 @@ public function validate(Address $address)
9394
if (!filter_var($address->getEmail(), FILTER_VALIDATE_EMAIL)) {
9495
$warnings[] = 'Email has a wrong format';
9596
}
96-
if (!filter_var(in_array($address->getAddressType(), [Address::TYPE_BILLING, Address::TYPE_SHIPPING]))) {
97+
if (!in_array($address->getAddressType(), [Address::TYPE_BILLING, Address::TYPE_SHIPPING])) {
9798
$warnings[] = 'Address type doesn\'t match required options';
9899
}
99100
return $warnings;
@@ -200,7 +201,7 @@ protected function isStateRequired($countryId)
200201
* Check whether telephone is required for address.
201202
*
202203
* @return bool
203-
* @throws \Magento\Framework\Exception\LocalizedException
204+
* @throws LocalizedException
204205
*/
205206
protected function isTelephoneRequired()
206207
{
@@ -211,7 +212,7 @@ protected function isTelephoneRequired()
211212
* Check whether company is required for address.
212213
*
213214
* @return bool
214-
* @throws \Magento\Framework\Exception\LocalizedException
215+
* @throws LocalizedException
215216
*/
216217
protected function isCompanyRequired()
217218
{
@@ -222,7 +223,7 @@ protected function isCompanyRequired()
222223
* Check whether telephone is required for address.
223224
*
224225
* @return bool
225-
* @throws \Magento\Framework\Exception\LocalizedException
226+
* @throws LocalizedException
226227
*/
227228
protected function isFaxRequired()
228229
{

dev/tests/integration/testsuite/Magento/Cron/Model/ScheduleTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class ScheduleTest extends \PHPUnit\Framework\TestCase
2525
*/
2626
protected $dateTime;
2727

28+
/**
29+
* @ingeritdoc
30+
*/
2831
protected function setUp(): void
2932
{
3033
$this->dateTime = Bootstrap::getObjectManager()->create(DateTime::class);
@@ -65,9 +68,9 @@ public function testTryLockJobAlreadyLockedSucceeds()
6568
->setCronExpr("* * * * *")
6669
->setJobCode("test_job")
6770
->setStatus(Schedule::STATUS_RUNNING)
68-
->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $this->dateTime->gmtTimestamp() - $offsetInThePast))
69-
->setScheduledAt(strftime('%Y-%m-%d %H:%M', $this->dateTime->gmtTimestamp() - $offsetInThePast + 60))
70-
->setExecutedAt(strftime('%Y-%m-%d %H:%M', $this->dateTime->gmtTimestamp() - $offsetInThePast + 61));
71+
->setCreatedAt(date('Y-m-d H:i:s', $this->dateTime->gmtTimestamp() - $offsetInThePast))
72+
->setScheduledAt(date('Y-m-d H:i', $this->dateTime->gmtTimestamp() - $offsetInThePast + 60))
73+
->setExecutedAt(date('Y-m-d H:i', $this->dateTime->gmtTimestamp() - $offsetInThePast + 61));
7174
$oldSchedule->save();
7275

7376
$schedule = $this->createSchedule("test_job", Schedule::STATUS_PENDING);
@@ -111,8 +114,8 @@ private function createSchedule($jobCode, $status, $timeOffset = 0)
111114
->setCronExpr("* * * * *")
112115
->setJobCode($jobCode)
113116
->setStatus($status)
114-
->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $this->dateTime->gmtTimestamp()))
115-
->setScheduledAt(strftime('%Y-%m-%d %H:%M', $this->dateTime->gmtTimestamp() + $timeOffset));
117+
->setCreatedAt(date('Y-m-d H:i:s', $this->dateTime->gmtTimestamp()))
118+
->setScheduledAt(date('Y-m-d H:i', $this->dateTime->gmtTimestamp() + $timeOffset));
116119
$schedule->save();
117120

118121
return $schedule;

dev/tests/utils/phpunitGroupConfig.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
$generateConfig = false;
9090
} else {
9191
assertUsage(
92-
(empty($options['get-group']) || !ctype_digit($options['get-group']))
92+
(empty($options['get-group']) || !(is_string($options['get-group']) && ctype_digit($options['get-group'])))
9393
&& strtolower($options['get-group']) != 'all',
9494
"Option --get-group: must be a positive integer or 'all'\n"
9595
);
@@ -121,7 +121,9 @@
121121
);
122122

123123
if (!$generateConfig) {
124+
//phpcs:ignore Magento2.Security.LanguageConstruct
124125
print $totalGroups;
126+
//phpcs:ignore Magento2.Security.LanguageConstruct
125127
exit(0);
126128
}
127129

@@ -150,10 +152,13 @@
150152
createGroupConfig($configFile, $groupConfigFile, $groupTests, $index);
151153
$successMsg .= "{$groupConfigFile}, group: {$index}, test suite: group_{$index}\n";
152154
}
155+
//phpcs:ignore Magento2.Security.LanguageConstruct
153156
print $successMsg;
154157

155158
} catch (Exception $e) {
159+
//phpcs:ignore Magento2.Security.LanguageConstruct
156160
print $e->getMessage();
161+
//phpcs:ignore Magento2.Security.LanguageConstruct
157162
exit(1);
158163
}
159164

@@ -164,8 +169,10 @@
164169
* @param string $out
165170
* @param array $group
166171
* @param integer $index
172+
*
167173
* @return void
168174
* @throws Exception
175+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
169176
*/
170177
function createGroupConfig($in, $out, $group, $index)
171178
{
@@ -230,7 +237,12 @@ function getFormattedGroup($group, $index)
230237
*
231238
* @param string $configFile
232239
* @param string $suiteName
240+
*
233241
* @return array
242+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
243+
* @SuppressWarnings(PHPMD.NPathComplexity)
244+
* @phpcs:disable Generic.Metrics.NestingLevel
245+
* @phpcs:disable Generic.Metrics.CyclomaticComplexity
234246
*/
235247
function getTestList($configFile, $suiteName)
236248
{

0 commit comments

Comments
 (0)