Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AggregateSalesReportCouponsDataTest.php
Go to the documentation of this file.
1 <?php
7 
8 class AggregateSalesReportCouponsDataTest extends \PHPUnit\Framework\TestCase
9 {
13  protected $model;
14 
18  protected $localeResolver;
19 
23  protected $localeDate;
24 
28  protected $reportRule;
29 
30  protected function setUp()
31  {
32  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
33  $this->initMocks();
34 
35  $this->model = $helper->getObject(
36  \Magento\SalesRule\Cron\AggregateSalesReportCouponsData::class,
37  [
38  'reportRule' => $this->reportRule,
39  'localeResolver' => $this->localeResolver,
40  'localeDate' => $this->localeDate,
41  ]
42  );
43  }
44 
45  protected function initMocks()
46  {
47  $this->localeResolver = $this->createMock(\Magento\Framework\Locale\Resolver::class);
48  $this->localeDate = $this->createPartialMock(\Magento\Framework\Stdlib\DateTime\Timezone::class, ['date']);
49  $this->reportRule = $this->createMock(\Magento\SalesRule\Model\ResourceModel\Report\Rule::class);
50  }
51 
52  public function testExecute()
53  {
54  $data = new \DateTime();
55  $this->localeResolver->expects($this->once())
56  ->method('emulate')
57  ->with(0);
58  $this->localeDate->expects($this->once())
59  ->method('date')
60  ->will($this->returnValue($data));
61  $this->reportRule->expects($this->once())
62  ->method('aggregate')
63  ->with($data);
64  $this->localeResolver->expects($this->once())
65  ->method('revert');
66 
67  $scheduleMock = $this->createMock(\Magento\Cron\Model\Schedule::class);
68 
69  $this->assertEquals($this->model, $this->model->execute($scheduleMock));
70  }
71 }
$helper
Definition: iframe.phtml:13