Skip to content

Commit

Permalink
MAGETWO-57835: [Github] Cannot save customer dob attribute if admin i…
Browse files Browse the repository at this point in the history
…nterface locale is en_GB #6323
  • Loading branch information
slopukhov committed Jul 3, 2017
1 parent b938571 commit 9a1ed3d
Showing 1 changed file with 42 additions and 32 deletions.
Expand Up @@ -70,6 +70,17 @@ protected function setUp()
->getMock();

$this->dataProviderMock = $this->getMockForAbstractClass(DataProviderInterface::class);

$this->contextMock->expects($this->any())
->method('getNamespace')
->willReturn(DateRange::NAME);
$this->contextMock->expects($this->any())
->method('addComponentDefinition')
->with(DateRange::NAME, ['extends' => DateRange::NAME]);

$this->contextMock->expects($this->any())
->method('getDataProvider')
->willReturn($this->dataProviderMock);
}

/**
Expand All @@ -84,29 +95,15 @@ protected function setUp()
*/
public function testPrepare($name, $filterData, $expectedCondition)
{
/** @var FormDate PHPUnit_Framework_MockObject_MockObject|$uiComponent */
$uiComponent = $this->getMockBuilder(FormDate::class)
->disableOriginalConstructor()
->getMock();

$uiComponent->expects($this->any())
->method('getContext')
->willReturn($this->contextMock);

$this->contextMock->expects($this->any())
->method('getNamespace')
->willReturn(DateRange::NAME);
$this->contextMock->expects($this->any())
->method('addComponentDefinition')
->with(DateRange::NAME, ['extends' => DateRange::NAME]);

$this->contextMock->expects($this->any())
->method('getFiltersParams')
->willReturn($filterData);

$this->contextMock->expects($this->any())
->method('getDataProvider')
->willReturn($this->dataProviderMock);
$uiComponent = $this->getMockBuilder(FormDate::class)->disableOriginalConstructor()->getMock();

$uiComponent->expects($this->any())
->method('getContext')
->willReturn($this->contextMock);

if ($expectedCondition !== null) {
if (is_string($filterData[$name])) {
Expand Down Expand Up @@ -173,20 +170,8 @@ public function testPrepare($name, $filterData, $expectedCondition)
new \DateTime($filterData[$name]['to'] . ' 23:59:00', new \DateTimeZone('UTC'))
],
]);
$this->filterBuilderMock->expects(static::exactly(2))
->method('setConditionType')
->willReturnSelf();
$this->filterBuilderMock->expects(static::exactly(2))
->method('setField')
->willReturnSelf();
$this->filterBuilderMock->expects(static::exactly(2))
->method('setValue')
->willReturnSelf();

$filterMock = $this->getMock(Filter::class);
$this->filterBuilderMock->expects(static::exactly(2))
->method('create')
->willReturn($filterMock);
$filterMock = $this->getFilterMockWithoutExpectedCondition();
$this->dataProviderMock->expects(static::exactly(2))
->method('addFilter')
->with($filterMock);
Expand Down Expand Up @@ -241,6 +226,31 @@ private function getFilterMock($name, $expectedType, $expectedDate, &$i)
return $filterMock;
}

/**
* Gets Filter mock without expected condition
*
* @return Filter|\PHPUnit_Framework_MockObject_MockObject
*/
private function getFilterMockWithoutExpectedCondition()
{
$this->filterBuilderMock->expects(static::exactly(2))
->method('setConditionType')
->willReturnSelf();
$this->filterBuilderMock->expects(static::exactly(2))
->method('setField')
->willReturnSelf();
$this->filterBuilderMock->expects(static::exactly(2))
->method('setValue')
->willReturnSelf();

$filterMock = $this->getMock(Filter::class);
$this->filterBuilderMock->expects(static::exactly(2))
->method('create')
->willReturn($filterMock);

return $filterMock;
}

/**
* @return array
*/
Expand Down

0 comments on commit 9a1ed3d

Please sign in to comment.