Skip to content

Commit

Permalink
[EngCom] Public Pull Requests - 2.2-develop
Browse files Browse the repository at this point in the history
 - merged latest code from mainline branch
  • Loading branch information
magento-engcom-team authored Feb 18, 2019
2 parents 109b4e9 + d18c713 commit aa8dfb0
Show file tree
Hide file tree
Showing 8 changed files with 216 additions and 49 deletions.
8 changes: 7 additions & 1 deletion app/code/Magento/Catalog/Block/Product/View/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Magento\Framework\Pricing\PriceCurrencyInterface;

/**
* Attributes attributes block
*
* @api
* @since 100.0.2
*/
Expand Down Expand Up @@ -56,6 +58,8 @@ public function __construct(
}

/**
* Returns a Product.
*
* @return Product
*/
public function getProduct()
Expand All @@ -67,6 +71,8 @@ public function getProduct()
}

/**
* Additional data.
*
* $excludeAttr is optional array of attribute codes to
* exclude them from additional data array
*
Expand All @@ -89,7 +95,7 @@ public function getAdditionalData(array $excludeAttr = [])
$value = $this->priceCurrency->convertAndFormat($value);
}

if (is_string($value) && strlen($value)) {
if (is_string($value) && strlen(trim($value))) {
$data[$attribute->getAttributeCode()] = [
'label' => __($attribute->getStoreLabel()),
'value' => $value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,28 @@ protected function setUp()
}

/**
* Get attribute with no value phrase
*
* @param string $phrase
* @return void
* @dataProvider noValueProvider
*/
public function testGetAttributeNoValue()
public function testGetAttributeNoValue(string $phrase)
{
$this->phrase = '';
$this->frontendAttribute
->expects($this->any())
->method('getValue')
->willReturn($this->phrase);
$this->frontendAttribute->method('getValue')
->willReturn($phrase);
$attributes = $this->attributesBlock->getAdditionalData();
$this->assertTrue(empty($attributes['phrase']));
$this->assertArrayNotHasKey('phrase', $attributes);
}

/**
* No value data provider
*
* @return array
*/
public function noValueProvider(): array
{
return [[' '], ['']];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@
$block->escapeUrl($block->getContinueShoppingUrl())) ?></p>
<?= $block->getChildHtml('shopping.cart.table.after') ?>
</div>
<script type="text/x-magento-init">
{
"*": {
"Magento_Checkout/js/empty-cart": {}
}
}
</script>
12 changes: 12 additions & 0 deletions app/code/Magento/Checkout/view/frontend/web/js/empty-cart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

define([
'Magento_Customer/js/customer-data'
], function (customerData) {
'use strict';

customerData.reload(['cart'], false);
});
30 changes: 21 additions & 9 deletions app/code/Magento/Cron/Model/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Framework\Exception\CronException;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\Intl\DateTimeFactory;

/**
* Crontab schedule model
Expand Down Expand Up @@ -50,24 +51,32 @@ class Schedule extends \Magento\Framework\Model\AbstractModel
*/
private $timezoneConverter;

/**
* @var DateTimeFactory
*/
private $dateTimeFactory;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @param TimezoneInterface $timezoneConverter
* @param TimezoneInterface|null $timezoneConverter
* @param DateTimeFactory|null $dateTimeFactory
*/
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
TimezoneInterface $timezoneConverter = null
TimezoneInterface $timezoneConverter = null,
DateTimeFactory $dateTimeFactory = null
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
$this->timezoneConverter = $timezoneConverter ?: ObjectManager::getInstance()->get(TimezoneInterface::class);
$this->dateTimeFactory = $dateTimeFactory ?: ObjectManager::getInstance()->get(DateTimeFactory::class);
}

/**
Expand Down Expand Up @@ -109,17 +118,20 @@ public function trySchedule()
if (!$e || !$time) {
return false;
}
$configTimeZone = $this->timezoneConverter->getConfigTimezone();
$storeDateTime = $this->dateTimeFactory->create(null, new \DateTimeZone($configTimeZone));
if (!is_numeric($time)) {
//convert time from UTC to admin store timezone
//we assume that all schedules in configuration (crontab.xml and DB tables) are in admin store timezone
$time = $this->timezoneConverter->date($time)->format('Y-m-d H:i');
$time = strtotime($time);
$dateTimeUtc = $this->dateTimeFactory->create($time);
$time = $dateTimeUtc->getTimestamp();
}
$match = $this->matchCronExpression($e[0], strftime('%M', $time))
&& $this->matchCronExpression($e[1], strftime('%H', $time))
&& $this->matchCronExpression($e[2], strftime('%d', $time))
&& $this->matchCronExpression($e[3], strftime('%m', $time))
&& $this->matchCronExpression($e[4], strftime('%w', $time));
$time = $storeDateTime->setTimestamp($time);
$match = $this->matchCronExpression($e[0], $time->format('i'))
&& $this->matchCronExpression($e[1], $time->format('H'))
&& $this->matchCronExpression($e[2], $time->format('d'))
&& $this->matchCronExpression($e[3], $time->format('m'))
&& $this->matchCronExpression($e[4], $time->format('w'));

return $match;
}
Expand Down
Loading

0 comments on commit aa8dfb0

Please sign in to comment.