Skip to content

Commit

Permalink
MAGETWO-84847: Prepare codebase for 2.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Idolov committed Feb 20, 2018
1 parent b2fd6f3 commit 14285b9
Show file tree
Hide file tree
Showing 122 changed files with 34,845 additions and 4,437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function getHtml()

/**
* @param string|null $index
* @return string
* @return array|string|int|float|null
*/
public function getEscapedValue($index = null)
{
Expand All @@ -136,6 +136,11 @@ public function getEscapedValue($index = null)
$this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT)
);
}

if (is_string($value)) {
return $this->escapeHtml($value);
}

return $value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public function getHtml()
/**
* Return escaped value for calendar
*
* @param string $index
* @return string
* @param string|null $index
* @return array|string|int|float|null
*/
public function getEscapedValue($index = null)
{
Expand All @@ -152,6 +152,11 @@ public function getEscapedValue($index = null)
if ($value instanceof \DateTime) {
return $this->_localeDate->formatDateTime($value);
}

if (is_string($value)) {
return $this->escapeHtml($value);
}

return $value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@ class DateTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->mathRandomMock = $this->getMockBuilder('Magento\Framework\Math\Random')
$this->mathRandomMock = $this->getMockBuilder(\Magento\Framework\Math\Random::class)
->disableOriginalConstructor()
->setMethods(['getUniqueHash'])
->getMock();

$this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface')
$this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->dateTimeFormatterMock = $this
->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface')
->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->columnMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column')
$this->columnMock = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid\Column::class)
->disableOriginalConstructor()
->setMethods(['getTimezone', 'getHtmlId', 'getId'])
->getMock();

$this->localeDateMock = $this->getMockBuilder('\Magento\Framework\Stdlib\DateTime\TimezoneInterface')
$this->localeDateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->model = $objectManagerHelper->getObject(
'Magento\Backend\Block\Widget\Grid\Column\Filter\Date',
\Magento\Backend\Block\Widget\Grid\Column\Filter\Date::class,
[
'mathRandom' => $this->mathRandomMock,
'localeResolver' => $this->localeResolverMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@ class DatetimeTest extends \PHPUnit_Framework_TestCase

protected function setUp()
{
$this->mathRandomMock = $this->getMockBuilder('Magento\Framework\Math\Random')
$this->mathRandomMock = $this->getMockBuilder(\Magento\Framework\Math\Random::class)
->disableOriginalConstructor()
->setMethods(['getUniqueHash'])
->getMock();

$this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface')
$this->localeResolverMock = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->dateTimeFormatterMock = $this
->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface')
->getMockBuilder(\Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$this->columnMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column')
$this->columnMock = $this->getMockBuilder(\Magento\Backend\Block\Widget\Grid\Column::class)
->disableOriginalConstructor()
->setMethods(['getTimezone', 'getHtmlId', 'getId'])
->getMock();

$this->localeDateMock = $this->getMockBuilder('\Magento\Framework\Stdlib\DateTime\TimezoneInterface')
$this->localeDateMock = $this->getMockBuilder(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class)
->disableOriginalConstructor()
->setMethods([])
->getMock();

$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->model = $objectManagerHelper->getObject(
'Magento\Backend\Block\Widget\Grid\Column\Filter\Datetime',
\Magento\Backend\Block\Widget\Grid\Column\Filter\Datetime::class,
[
'mathRandom' => $this->mathRandomMock,
'localeResolver' => $this->localeResolverMock,
Expand Down
22 changes: 16 additions & 6 deletions app/code/Magento/Backup/Controller/Adminhtml/Index/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
class Create extends \Magento\Backup\Controller\Adminhtml\Index
{
/**
* Create backup action
* Create backup action.
*
* @return void|\Magento\Backend\App\Action
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function execute()
{
if (!$this->getRequest()->isAjax()) {
if (!$this->requestAllowed()) {
return $this->_redirect('*/*/index');
}

Expand All @@ -28,7 +28,7 @@ public function execute()
/**
* @var \Magento\Backup\Helper\Data $helper
*/
$helper = $this->_objectManager->get('Magento\Backup\Helper\Data');
$helper = $this->_objectManager->get(\Magento\Backup\Helper\Data::class);

try {
$type = $this->getRequest()->getParam('type');
Expand Down Expand Up @@ -73,7 +73,7 @@ public function execute()

if ($type != \Magento\Framework\Backup\Factory::TYPE_DB) {
/** @var Filesystem $filesystem */
$filesystem = $this->_objectManager->get('Magento\Framework\Filesystem');
$filesystem = $this->_objectManager->get(\Magento\Framework\Filesystem::class);
$backupManager->setRootDir($filesystem->getDirectoryRead(DirectoryList::ROOT)->getAbsolutePath())
->addIgnorePaths($helper->getBackupIgnorePaths());
}
Expand All @@ -88,10 +88,10 @@ public function execute()
} catch (\Magento\Framework\Backup\Exception\NotEnoughFreeSpace $e) {
$errorMessage = __('You need more free space to create a backup.');
} catch (\Magento\Framework\Backup\Exception\NotEnoughPermissions $e) {
$this->_objectManager->get('Psr\Log\LoggerInterface')->info($e->getMessage());
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->info($e->getMessage());
$errorMessage = __('You need more permissions to create a backup.');
} catch (\Exception $e) {
$this->_objectManager->get('Psr\Log\LoggerInterface')->info($e->getMessage());
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->info($e->getMessage());
$errorMessage = __('We can\'t create the backup right now.');
}

Expand All @@ -106,4 +106,14 @@ public function execute()

$this->getResponse()->representJson($response->toJson());
}

/**
* Check if request is allowed.
*
* @return bool
*/
private function requestAllowed()
{
return $this->getRequest()->isAjax() && $this->getRequest()->isPost();
}
}

0 comments on commit 14285b9

Please sign in to comment.