Skip to content

Commit 952abad

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-67431
2 parents dfcc24f + 5c4ee14 commit 952abad

File tree

32 files changed

+433
-178
lines changed

32 files changed

+433
-178
lines changed

app/code/Magento/CatalogInventory/Model/Stock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Stock extends AbstractExtensibleModel implements StockInterface
3232
*
3333
* @var string
3434
*/
35-
protected $eventObject = 'stock';
35+
protected $_eventObject = 'stock';
3636

3737
const BACKORDERS_NO = 0;
3838

app/code/Magento/CatalogInventory/Model/Stock/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Item extends AbstractExtensibleModel implements StockItemInterface
4343
*
4444
* @var string
4545
*/
46-
protected $eventObject = 'item';
46+
protected $_eventObject = 'item';
4747

4848
/**
4949
* Store model manager

app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -477,33 +477,37 @@ public function getQtyIncrementsDataProvider()
477477
*
478478
* @param $eventName
479479
* @param $methodName
480+
* @param $objectName
480481
*
481482
* @dataProvider eventsDataProvider
482483
*/
483-
public function testDispatchEvents($eventName, $methodName)
484+
public function testDispatchEvents($eventName, $methodName, $objectName)
484485
{
485486
$isCalledWithRightPrefix = 0;
487+
$isObjectNameRight = 0;
486488
$this->eventDispatcher->expects($this->any())->method('dispatch')->with(
487489
$this->callback(function ($arg) use (&$isCalledWithRightPrefix, $eventName) {
488490
$isCalledWithRightPrefix |= ($arg === $eventName);
489491
return true;
490492
}),
491-
$this->anything()
493+
$this->callback(function ($data) use (&$isObjectNameRight, $objectName) {
494+
$isObjectNameRight |= isset($data[$objectName]);
495+
return true;
496+
})
492497
);
493498

494499
$this->item->$methodName();
495-
$this->assertEquals(
496-
1,
497-
(int) $isCalledWithRightPrefix,
498-
sprintf("Event %s doesn't dispatched", $eventName)
500+
$this->assertTrue(
501+
($isCalledWithRightPrefix && $isObjectNameRight),
502+
sprintf('Event "%s" with object name "%s" doesn\'t dispatched properly', $eventName, $objectName)
499503
);
500504
}
501505

502506
public function eventsDataProvider()
503507
{
504508
return [
505-
['cataloginventory_stock_item_save_before', 'beforeSave'],
506-
['cataloginventory_stock_item_save_after', 'afterSave'],
509+
['cataloginventory_stock_item_save_before', 'beforeSave', 'item'],
510+
['cataloginventory_stock_item_save_after', 'afterSave', 'item'],
507511
];
508512
}
509513
}

app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,33 +100,37 @@ public function setUp()
100100
*
101101
* @param $eventName
102102
* @param $methodName
103+
* @param $objectName
103104
*
104105
* @dataProvider eventsDataProvider
105106
*/
106-
public function testDispatchEvents($eventName, $methodName)
107+
public function testDispatchEvents($eventName, $methodName, $objectName)
107108
{
108109
$isCalledWithRightPrefix = 0;
110+
$isObjectNameRight = 0;
109111
$this->eventDispatcher->expects($this->any())->method('dispatch')->with(
110112
$this->callback(function ($arg) use (&$isCalledWithRightPrefix, $eventName) {
111113
$isCalledWithRightPrefix |= ($arg === $eventName);
112114
return true;
113115
}),
114-
$this->anything()
116+
$this->callback(function ($data) use (&$isObjectNameRight, $objectName) {
117+
$isObjectNameRight |= isset($data[$objectName]);
118+
return true;
119+
})
115120
);
116121

117122
$this->stockModel->$methodName();
118-
$this->assertEquals(
119-
1,
120-
(int) $isCalledWithRightPrefix,
121-
sprintf("Event %s doesn't dispatched", $eventName)
123+
$this->assertTrue(
124+
($isCalledWithRightPrefix && $isObjectNameRight),
125+
sprintf('Event "%s" with object name "%s" doesn\'t dispatched properly', $eventName, $objectName)
122126
);
123127
}
124128

125129
public function eventsDataProvider()
126130
{
127131
return [
128-
['cataloginventory_stock_save_before', 'beforeSave'],
129-
['cataloginventory_stock_save_after', 'afterSave'],
132+
['cataloginventory_stock_save_before', 'beforeSave', 'stock'],
133+
['cataloginventory_stock_save_after', 'afterSave', 'stock'],
130134
];
131135
}
132136
}

app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,26 +315,35 @@ protected function getMultilineFieldConfig($attributeCode, array $attributeConfi
315315
*/
316316
protected function getDefaultValue($attributeCode)
317317
{
318+
if ($attributeCode === 'country_id') {
319+
return $this->directoryHelper->getDefaultCountry();
320+
}
321+
322+
$customer = $this->getCustomer();
323+
if ($customer === null) {
324+
return null;
325+
}
326+
327+
$attributeValue = null;
318328
switch ($attributeCode) {
329+
case 'prefix':
330+
$attributeValue = $customer->getPrefix();
331+
break;
319332
case 'firstname':
320-
if ($this->getCustomer()) {
321-
return $this->getCustomer()->getFirstname();
322-
}
333+
$attributeValue = $customer->getFirstname();
323334
break;
324335
case 'middlename':
325-
if ($this->getCustomer()) {
326-
return $this->getCustomer()->getMiddlename();
327-
}
336+
$attributeValue = $customer->getMiddlename();
328337
break;
329338
case 'lastname':
330-
if ($this->getCustomer()) {
331-
return $this->getCustomer()->getLastname();
332-
}
339+
$attributeValue = $customer->getLastname();
340+
break;
341+
case 'suffix':
342+
$attributeValue = $customer->getSuffix();
333343
break;
334-
case 'country_id':
335-
return $this->directoryHelper->getDefaultCountry();
336344
}
337-
return null;
345+
346+
return $attributeValue;
338347
}
339348

340349
/**

app/code/Magento/Cron/Observer/ProcessCronQueueObserver.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ class ProcessCronQueueObserver implements ObserverInterface
9797
protected $_shell;
9898

9999
/**
100-
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
100+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
101101
*/
102-
protected $timezone;
102+
protected $dateTime;
103103

104104
/**
105105
* @var \Symfony\Component\Process\PhpExecutableFinder
@@ -124,7 +124,7 @@ class ProcessCronQueueObserver implements ObserverInterface
124124
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
125125
* @param \Magento\Framework\App\Console\Request $request
126126
* @param \Magento\Framework\ShellInterface $shell
127-
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
127+
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
128128
* @param \Magento\Framework\Process\PhpExecutableFinderFactory $phpExecutableFinderFactory
129129
* @param \Psr\Log\LoggerInterface $logger
130130
* @param \Magento\Framework\App\State $state
@@ -138,7 +138,7 @@ public function __construct(
138138
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
139139
\Magento\Framework\App\Console\Request $request,
140140
\Magento\Framework\ShellInterface $shell,
141-
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
141+
\Magento\Framework\Stdlib\DateTime\DateTime $dateTime,
142142
\Magento\Framework\Process\PhpExecutableFinderFactory $phpExecutableFinderFactory,
143143
\Psr\Log\LoggerInterface $logger,
144144
\Magento\Framework\App\State $state
@@ -150,7 +150,7 @@ public function __construct(
150150
$this->_scopeConfig = $scopeConfig;
151151
$this->_request = $request;
152152
$this->_shell = $shell;
153-
$this->timezone = $timezone;
153+
$this->dateTime = $dateTime;
154154
$this->phpExecutableFinder = $phpExecutableFinderFactory->create();
155155
$this->logger = $logger;
156156
$this->state = $state;
@@ -170,7 +170,7 @@ public function __construct(
170170
public function execute(\Magento\Framework\Event\Observer $observer)
171171
{
172172
$pendingJobs = $this->_getPendingSchedules();
173-
$currentTime = $this->timezone->scopeTimeStamp();
173+
$currentTime = $this->dateTime->gmtTimestamp();
174174
$jobGroupsRoot = $this->_config->getJobs();
175175

176176
$phpPath = $this->phpExecutableFinder->find() ?: 'php';
@@ -274,7 +274,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
274274
);
275275
}
276276

277-
$schedule->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', $this->timezone->scopeTimeStamp()))->save();
277+
$schedule->setExecutedAt(strftime('%Y-%m-%d %H:%M:%S', $this->dateTime->gmtTimestamp()))->save();
278278

279279
try {
280280
call_user_func_array($callback, [$schedule]);
@@ -285,7 +285,7 @@ protected function _runJob($scheduledTime, $currentTime, $jobConfig, $schedule,
285285

286286
$schedule->setStatus(Schedule::STATUS_SUCCESS)->setFinishedAt(strftime(
287287
'%Y-%m-%d %H:%M:%S',
288-
$this->timezone->scopeTimeStamp()
288+
$this->dateTime->gmtTimestamp()
289289
));
290290
}
291291

@@ -322,7 +322,7 @@ protected function _generate($groupId)
322322
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
323323
);
324324
$schedulePeriod = $rawSchedulePeriod * self::SECONDS_IN_MINUTE;
325-
if ($lastRun > $this->timezone->scopeTimeStamp() - $schedulePeriod) {
325+
if ($lastRun > $this->dateTime->gmtTimestamp() - $schedulePeriod) {
326326
return $this;
327327
}
328328

@@ -343,7 +343,7 @@ protected function _generate($groupId)
343343
* save time schedules generation was ran with no expiration
344344
*/
345345
$this->_cache->save(
346-
$this->timezone->scopeTimeStamp(),
346+
$this->dateTime->gmtTimestamp(),
347347
self::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT . $groupId,
348348
['crontab'],
349349
null
@@ -398,7 +398,7 @@ protected function _cleanup($groupId)
398398
'system/cron/' . $groupId . '/' . self::XML_PATH_HISTORY_CLEANUP_EVERY,
399399
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
400400
);
401-
if ($lastCleanup > $this->timezone->scopeTimeStamp() - $historyCleanUp * self::SECONDS_IN_MINUTE) {
401+
if ($lastCleanup > $this->dateTime->gmtTimestamp() - $historyCleanUp * self::SECONDS_IN_MINUTE) {
402402
return $this;
403403
}
404404

@@ -431,7 +431,7 @@ protected function _cleanup($groupId)
431431
Schedule::STATUS_ERROR => $historyFailure * self::SECONDS_IN_MINUTE,
432432
];
433433

434-
$now = $this->timezone->scopeTimeStamp();
434+
$now = $this->dateTime->gmtTimestamp();
435435
/** @var Schedule $record */
436436
foreach ($history as $record) {
437437
$checkTime = $record->getExecutedAt() ? strtotime($record->getExecutedAt()) :
@@ -443,7 +443,7 @@ protected function _cleanup($groupId)
443443

444444
// save time history cleanup was ran with no expiration
445445
$this->_cache->save(
446-
$this->timezone->scopeTimeStamp(),
446+
$this->dateTime->gmtTimestamp(),
447447
self::CACHE_KEY_LAST_HISTORY_CLEANUP_AT . $groupId,
448448
['crontab'],
449449
null
@@ -475,7 +475,7 @@ protected function getConfigSchedule($jobConfig)
475475
*/
476476
protected function saveSchedule($jobCode, $cronExpression, $timeInterval, $exists)
477477
{
478-
$currentTime = $this->timezone->scopeTimeStamp();
478+
$currentTime = $this->dateTime->gmtTimestamp();
479479
$timeAhead = $currentTime + $timeInterval;
480480
for ($time = $currentTime; $time < $timeAhead; $time += self::SECONDS_IN_MINUTE) {
481481
$ts = strftime('%Y-%m-%d %H:%M:00', $time);
@@ -503,7 +503,7 @@ protected function generateSchedule($jobCode, $cronExpression, $time)
503503
->setCronExpr($cronExpression)
504504
->setJobCode($jobCode)
505505
->setStatus(Schedule::STATUS_PENDING)
506-
->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $this->timezone->scopeTimeStamp()))
506+
->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $this->dateTime->gmtTimestamp()))
507507
->setScheduledAt(strftime('%Y-%m-%d %H:%M', $time));
508508

509509
return $schedule;

app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ class ProcessCronQueueObserverTest extends \PHPUnit_Framework_TestCase
6464
protected $_cronGroupConfig;
6565

6666
/**
67-
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
67+
* @var \Magento\Framework\Stdlib\DateTime\DateTime
6868
*/
69-
protected $timezone;
69+
protected $dateTimeMock;
7070

7171
/**
7272
* @var \Magento\Framework\Event\Observer
@@ -126,8 +126,10 @@ protected function setUp()
126126

127127
$this->observer = $this->getMock(\Magento\Framework\Event\Observer::class, [], [], '', false);
128128

129-
$this->timezone = $this->getMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
130-
$this->timezone->expects($this->any())->method('scopeTimeStamp')->will($this->returnValue(time()));
129+
$this->dateTimeMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTime::class)
130+
->disableOriginalConstructor()
131+
->getMock();
132+
$this->dateTimeMock->expects($this->any())->method('gmtTimestamp')->will($this->returnValue(time()));
131133

132134
$phpExecutableFinder = $this->getMock(\Symfony\Component\Process\PhpExecutableFinder::class, [], [], '', false);
133135
$phpExecutableFinder->expects($this->any())->method('find')->willReturn('php');
@@ -148,7 +150,7 @@ protected function setUp()
148150
$this->_scopeConfig,
149151
$this->_request,
150152
$this->_shell,
151-
$this->timezone,
153+
$this->dateTimeMock,
152154
$phpExecutableFinderFactory,
153155
$this->loggerMock,
154156
$this->appStateMock

app/code/Magento/Deploy/Console/DeployStaticOptions.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class DeployStaticOptions
131131
*/
132132
const CONTENT_VERSION = 'content-version';
133133

134+
/**
135+
* Key for refresh content version only mode
136+
*/
137+
const REFRESH_CONTENT_VERSION_ONLY = 'refresh-content-version-only';
138+
134139
/**
135140
* Deploy static command options list
136141
*
@@ -225,6 +230,13 @@ private function getBasicOptions()
225230
'Custom version of static content can be used if running deployment on multiple nodes '
226231
. 'to ensure that static content version is identical and caching works properly.'
227232
),
233+
new InputOption(
234+
self::REFRESH_CONTENT_VERSION_ONLY,
235+
null,
236+
InputOption::VALUE_NONE,
237+
'Refreshing the version of static content only can be used to refresh static content '
238+
. 'in browser cache and CDN cache.'
239+
),
228240
new InputArgument(
229241
self::LANGUAGES_ARGUMENT,
230242
InputArgument::IS_ARRAY,

0 commit comments

Comments
 (0)