Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
ExportDataHandlerNotificationTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13 class ExportDataHandlerNotificationTest extends \PHPUnit\Framework\TestCase
14 {
18  private $objectManagerHelper;
19 
23  public function setUp()
24  {
25  $this->objectManagerHelper = new ObjectManagerHelper($this);
26  }
27 
31  public function testThatNotifyExecuted()
32  {
33  $expectedResult = true;
34  $notifyCommandName = 'notifyDataChanged';
35  $exportDataHandlerMockObject = $this->createExportDataHandlerMock();
36  $analyticsConnectorMockObject = $this->createAnalyticsConnectorMock();
40  $exportDataHandlerNotification = $this->objectManagerHelper->getObject(
41  ExportDataHandlerNotification::class,
42  [
43  'exportDataHandler' => $exportDataHandlerMockObject,
44  'connector' => $analyticsConnectorMockObject,
45  ]
46  );
47  $exportDataHandlerMockObject->expects($this->once())
48  ->method('prepareExportData')
49  ->willReturn($expectedResult);
50  $analyticsConnectorMockObject->expects($this->once())
51  ->method('execute')
52  ->with($notifyCommandName);
53  $this->assertEquals($expectedResult, $exportDataHandlerNotification->prepareExportData());
54  }
55 
59  private function createExportDataHandlerMock()
60  {
61  return $this->getMockBuilder(ExportDataHandler::class)->disableOriginalConstructor()->getMock();
62  }
63 
67  private function createAnalyticsConnectorMock()
68  {
69  return $this->getMockBuilder(Connector::class)->disableOriginalConstructor()->getMock();
70  }
71 }