-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from magento-extensibility/time-zone-pr
[Extensibility] MAGETWO-45241, MAGETWO-45240, MAGETWO-45251, MAGETWO-45237, MAGETWO-45274
- Loading branch information
Showing
19 changed files
with
356 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
* | ||
* @author Magento Core Team <[email protected]> | ||
*/ | ||
class PredispathAdminActionControllerObserver implements ObserverInterface | ||
class PredispatchAdminActionControllerObserver implements ObserverInterface | ||
{ | ||
/** | ||
* @var \Magento\AdminNotification\Model\FeedFactory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DateTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Backend\Test\Unit\Block\Widget\Grid\Column\Filter; | ||
|
||
/** | ||
* Class DateTest to test Magento\Backend\Block\Widget\Grid\Column\Filter\Date | ||
* | ||
*/ | ||
class DateTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var \Magento\Backend\Block\Widget\Grid\Column\Filter\Date */ | ||
protected $model; | ||
|
||
/** @var \Magento\Framework\Math\Random|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $mathRandomMock; | ||
|
||
/** @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $localeResolverMock; | ||
|
||
/** @var \Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $dateTimeFormatterMock; | ||
|
||
/** @var \Magento\Backend\Block\Widget\Grid\Column|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $columnMock; | ||
|
||
/** @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $localeDateMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->mathRandomMock = $this->getMockBuilder('Magento\Framework\Math\Random') | ||
->disableOriginalConstructor() | ||
->setMethods(['getUniqueHash']) | ||
->getMock(); | ||
|
||
$this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->dateTimeFormatterMock = $this | ||
->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->columnMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') | ||
->disableOriginalConstructor() | ||
->setMethods(['getTimezone', 'getHtmlId', 'getId']) | ||
->getMock(); | ||
|
||
$this->localeDateMock = $this->getMockBuilder('\Magento\Framework\Stdlib\DateTime\TimezoneInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->model = $objectManagerHelper->getObject( | ||
'Magento\Backend\Block\Widget\Grid\Column\Filter\Date', | ||
[ | ||
'mathRandom' => $this->mathRandomMock, | ||
'localeResolver' => $this->localeResolverMock, | ||
'dateTimeFormatter' => $this->dateTimeFormatterMock, | ||
'localeDate' => $this->localeDateMock | ||
] | ||
); | ||
$this->model->setColumn($this->columnMock); | ||
} | ||
|
||
public function testGetHtmlSuccessfulTimestamp() | ||
{ | ||
$uniqueHash = 'H@$H'; | ||
$id = 3; | ||
$format = 'mm/dd/yyyy'; | ||
$yesterday = new \DateTime(); | ||
$yesterday->add(\DateInterval::createFromDateString('yesterday')); | ||
$tomorrow = new \DateTime(); | ||
$tomorrow->add(\DateInterval::createFromDateString('tomorrow')); | ||
$value = [ | ||
'locale' => 'en_US', | ||
'from' => $yesterday->getTimestamp(), | ||
'to' => $tomorrow->getTimestamp() | ||
]; | ||
|
||
$this->mathRandomMock->expects($this->any())->method('getUniqueHash')->willReturn($uniqueHash); | ||
$this->columnMock->expects($this->once())->method('getHtmlId')->willReturn($id); | ||
$this->localeDateMock->expects($this->any())->method('getDateFormat')->willReturn($format); | ||
$this->columnMock->expects($this->any())->method('getTimezone')->willReturn(false); | ||
$this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn('en_US'); | ||
$this->model->setColumn($this->columnMock); | ||
$this->model->setValue($value); | ||
|
||
$output = $this->model->getHtml(); | ||
$this->assertContains('id="' . $uniqueHash . '_from" value="' . $yesterday->getTimestamp(), $output); | ||
$this->assertContains('id="' . $uniqueHash . '_to" value="' . $tomorrow->getTimestamp(), $output); | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/DatetimeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Backend\Test\Unit\Block\Widget\Grid\Column\Filter; | ||
|
||
/** | ||
* Class DateTimeTest to test Magento\Backend\Block\Widget\Grid\Column\Filter\Date | ||
* | ||
*/ | ||
class DatetimeTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** @var \Magento\Backend\Block\Widget\Grid\Column\Filter\Datetime */ | ||
protected $model; | ||
|
||
/** @var \Magento\Framework\Math\Random|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $mathRandomMock; | ||
|
||
/** @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $localeResolverMock; | ||
|
||
/** @var \Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $dateTimeFormatterMock; | ||
|
||
/** @var \Magento\Backend\Block\Widget\Grid\Column|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $columnMock; | ||
|
||
/** @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject */ | ||
protected $localeDateMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->mathRandomMock = $this->getMockBuilder('Magento\Framework\Math\Random') | ||
->disableOriginalConstructor() | ||
->setMethods(['getUniqueHash']) | ||
->getMock(); | ||
|
||
$this->localeResolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->dateTimeFormatterMock = $this | ||
->getMockBuilder('Magento\Framework\Stdlib\DateTime\DateTimeFormatterInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->columnMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column') | ||
->disableOriginalConstructor() | ||
->setMethods(['getTimezone', 'getHtmlId', 'getId']) | ||
->getMock(); | ||
|
||
$this->localeDateMock = $this->getMockBuilder('\Magento\Framework\Stdlib\DateTime\TimezoneInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->model = $objectManagerHelper->getObject( | ||
'Magento\Backend\Block\Widget\Grid\Column\Filter\Datetime', | ||
[ | ||
'mathRandom' => $this->mathRandomMock, | ||
'localeResolver' => $this->localeResolverMock, | ||
'dateTimeFormatter' => $this->dateTimeFormatterMock, | ||
'localeDate' => $this->localeDateMock | ||
] | ||
); | ||
$this->model->setColumn($this->columnMock); | ||
} | ||
|
||
public function testGetHtmlSuccessfulTimestamp() | ||
{ | ||
$uniqueHash = 'H@$H'; | ||
$id = 3; | ||
$format = 'mm/dd/yyyy'; | ||
$yesterday = new \DateTime(); | ||
$yesterday->add(\DateInterval::createFromDateString('yesterday')); | ||
$tomorrow = new \DateTime(); | ||
$tomorrow->add(\DateInterval::createFromDateString('tomorrow')); | ||
$value = [ | ||
'locale' => 'en_US', | ||
'from' => $yesterday->getTimestamp(), | ||
'to' => $tomorrow->getTimestamp() | ||
]; | ||
|
||
$this->mathRandomMock->expects($this->any())->method('getUniqueHash')->willReturn($uniqueHash); | ||
$this->columnMock->expects($this->once())->method('getHtmlId')->willReturn($id); | ||
$this->localeDateMock->expects($this->any())->method('getDateFormat')->willReturn($format); | ||
$this->columnMock->expects($this->any())->method('getTimezone')->willReturn(false); | ||
$this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn('en_US'); | ||
$this->model->setColumn($this->columnMock); | ||
$this->model->setValue($value); | ||
|
||
$output = $this->model->getHtml(); | ||
$this->assertContains('id="' . $uniqueHash . '_from" value="' . $yesterday->getTimestamp(), $output); | ||
$this->assertContains('id="' . $uniqueHash . '_to" value="' . $tomorrow->getTimestamp(), $output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.