Skip to content

Commit 3fc757d

Browse files
committed
MAGETWO-39354: Fix Static Tests
1 parent cf05bdf commit 3fc757d

File tree

2 files changed

+278
-278
lines changed

2 files changed

+278
-278
lines changed
Lines changed: 145 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,145 @@
1-
<?php
2-
/**
3-
* Copyright © 2015 Magento. All rights reserved.
4-
* See COPYING.txt for license details.
5-
*/
6-
7-
namespace Magento\Reports\Test\Unit\Block\Adminhtml\Sales\Grid\Column\Renderer;
8-
9-
use Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date;
10-
11-
class DateTest extends \PHPUnit_Framework_TestCase
12-
{
13-
/**
14-
* @var \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date
15-
*/
16-
protected $date;
17-
18-
/**
19-
* @var \Magento\Backend\Block\Context|\PHPUnit_Framework_MockObject_MockObject
20-
*/
21-
protected $contextMock;
22-
23-
/**
24-
* @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
25-
*/
26-
protected $resolverMock;
27-
28-
/**
29-
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
30-
*/
31-
protected $localeDate;
32-
33-
/**
34-
* {@inheritDoc}
35-
*/
36-
protected function setUp()
37-
{
38-
$this->localeDate = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface')
39-
->disableOriginalConstructor()
40-
->getMock();
41-
$this->localeDate
42-
->expects($this->once())
43-
->method('date')
44-
->will($this->returnArgument(0));
45-
46-
$this->contextMock = $this->getMockBuilder('Magento\Backend\Block\Context')
47-
->disableOriginalConstructor()
48-
->getMock();
49-
$this->contextMock
50-
->expects($this->once())
51-
->method('getLocaleDate')
52-
->will($this->returnValue($this->localeDate));
53-
54-
$this->resolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface')
55-
->getMock();
56-
57-
$this->date = new Date(
58-
$this->contextMock,
59-
$this->resolverMock
60-
);
61-
}
62-
63-
/**
64-
* @param string $data
65-
* @param string $index
66-
* @param string $locale
67-
* @param string $period
68-
* @param string $result
69-
* @dataProvider datesDataProvider
70-
* @return void
71-
*/
72-
public function testRender($data, $index, $locale, $period, $result)
73-
{
74-
$this->resolverMock->expects($this->any())->method('getLocale')->will($this->returnValue($locale));
75-
$this->localeDate->expects($this->any())->method('getDateFormat')->willReturnCallback(
76-
function ($value) use ($locale) {
77-
return (new \IntlDateFormatter(
78-
$locale,
79-
$value,
80-
\IntlDateFormatter::NONE
81-
))->getPattern();
82-
}
83-
);
84-
85-
$objectMock = $this->getMockBuilder('Magento\Framework\Object')
86-
->setMethods(['getData'])
87-
->getMock();
88-
$objectMock->expects($this->once())->method('getData')->will($this->returnValue($data));
89-
90-
$columnMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column')
91-
->disableOriginalConstructor()
92-
->setMethods(['getIndex', 'getPeriodType'])
93-
->getMock();
94-
$columnMock->expects($this->once())->method('getIndex')->will($this->returnValue($index));
95-
$columnMock->expects($this->atLeastOnce())->method('getPeriodType')->will($this->returnValue($period));
96-
97-
$this->date->setColumn($columnMock);
98-
99-
$this->assertEquals($result, $this->date->render($objectMock));
100-
}
101-
102-
/**
103-
* @return array
104-
*/
105-
public function datesDataProvider()
106-
{
107-
return [
108-
[
109-
'data' => '2000',
110-
'index' => 'period',
111-
'locale' => 'en_US',
112-
'period' => 'year',
113-
'result' => '2000'
114-
],
115-
[
116-
'data' => '2030',
117-
'index' => 'period',
118-
'locale' => 'en_US',
119-
'period' => 'year',
120-
'result' => '2030'
121-
],
122-
[
123-
'data' => '2000-01',
124-
'index' => 'period',
125-
'locale' => 'en_US',
126-
'period' => 'month',
127-
'result' => '1/2000'
128-
],
129-
[
130-
'data' => '2030-12',
131-
'index' => 'period',
132-
'locale' => 'en_US',
133-
'period' => 'month',
134-
'result' => '12/2030'
135-
],
136-
[
137-
'data' => '2014-06-25',
138-
'index' => 'period',
139-
'locale' => 'en_US',
140-
'period' => 'day',
141-
'result' => 'Jun 25, 2014'
142-
]
143-
];
144-
}
145-
}
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Reports\Test\Unit\Block\Adminhtml\Sales\Grid\Column\Renderer;
8+
9+
use Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date;
10+
11+
class DateTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Reports\Block\Adminhtml\Sales\Grid\Column\Renderer\Date
15+
*/
16+
protected $date;
17+
18+
/**
19+
* @var \Magento\Backend\Block\Context|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
protected $contextMock;
22+
23+
/**
24+
* @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
protected $resolverMock;
27+
28+
/**
29+
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
protected $localeDate;
32+
33+
/**
34+
* {@inheritDoc}
35+
*/
36+
protected function setUp()
37+
{
38+
$this->localeDate = $this->getMockBuilder('Magento\Framework\Stdlib\DateTime\TimezoneInterface')
39+
->disableOriginalConstructor()
40+
->getMock();
41+
$this->localeDate
42+
->expects($this->once())
43+
->method('date')
44+
->will($this->returnArgument(0));
45+
46+
$this->contextMock = $this->getMockBuilder('Magento\Backend\Block\Context')
47+
->disableOriginalConstructor()
48+
->getMock();
49+
$this->contextMock
50+
->expects($this->once())
51+
->method('getLocaleDate')
52+
->will($this->returnValue($this->localeDate));
53+
54+
$this->resolverMock = $this->getMockBuilder('Magento\Framework\Locale\ResolverInterface')
55+
->getMock();
56+
57+
$this->date = new Date(
58+
$this->contextMock,
59+
$this->resolverMock
60+
);
61+
}
62+
63+
/**
64+
* @param string $data
65+
* @param string $index
66+
* @param string $locale
67+
* @param string $period
68+
* @param string $result
69+
* @dataProvider datesDataProvider
70+
* @return void
71+
*/
72+
public function testRender($data, $index, $locale, $period, $result)
73+
{
74+
$this->resolverMock->expects($this->any())->method('getLocale')->will($this->returnValue($locale));
75+
$this->localeDate->expects($this->any())->method('getDateFormat')->willReturnCallback(
76+
function ($value) use ($locale) {
77+
return (new \IntlDateFormatter(
78+
$locale,
79+
$value,
80+
\IntlDateFormatter::NONE
81+
))->getPattern();
82+
}
83+
);
84+
85+
$objectMock = $this->getMockBuilder('Magento\Framework\Object')
86+
->setMethods(['getData'])
87+
->getMock();
88+
$objectMock->expects($this->once())->method('getData')->will($this->returnValue($data));
89+
90+
$columnMock = $this->getMockBuilder('Magento\Backend\Block\Widget\Grid\Column')
91+
->disableOriginalConstructor()
92+
->setMethods(['getIndex', 'getPeriodType'])
93+
->getMock();
94+
$columnMock->expects($this->once())->method('getIndex')->will($this->returnValue($index));
95+
$columnMock->expects($this->atLeastOnce())->method('getPeriodType')->will($this->returnValue($period));
96+
97+
$this->date->setColumn($columnMock);
98+
99+
$this->assertEquals($result, $this->date->render($objectMock));
100+
}
101+
102+
/**
103+
* @return array
104+
*/
105+
public function datesDataProvider()
106+
{
107+
return [
108+
[
109+
'data' => '2000',
110+
'index' => 'period',
111+
'locale' => 'en_US',
112+
'period' => 'year',
113+
'result' => '2000'
114+
],
115+
[
116+
'data' => '2030',
117+
'index' => 'period',
118+
'locale' => 'en_US',
119+
'period' => 'year',
120+
'result' => '2030'
121+
],
122+
[
123+
'data' => '2000-01',
124+
'index' => 'period',
125+
'locale' => 'en_US',
126+
'period' => 'month',
127+
'result' => '1/2000'
128+
],
129+
[
130+
'data' => '2030-12',
131+
'index' => 'period',
132+
'locale' => 'en_US',
133+
'period' => 'month',
134+
'result' => '12/2030'
135+
],
136+
[
137+
'data' => '2014-06-25',
138+
'index' => 'period',
139+
'locale' => 'en_US',
140+
'period' => 'day',
141+
'result' => 'Jun 25, 2014'
142+
]
143+
];
144+
}
145+
}

0 commit comments

Comments
 (0)