Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SynchronizeWebsiteAttributesTest.php
Go to the documentation of this file.
1 <?php
8 
11 
16 class SynchronizeWebsiteAttributesTest extends \PHPUnit\Framework\TestCase
17 {
18  public function testExecuteSuccess()
19  {
20  $synchronizerMock = $this->getMockBuilder(WebsiteAttributesSynchronizer::class)
21  ->disableOriginalConstructor()
22  ->setMethods([
23  'isSynchronizationRequired',
24  'synchronize',
25  ])
26  ->getMock();
27 
28  $synchronizerMock->expects($this->once())
29  ->method('isSynchronizationRequired')
30  ->will(
31  $this->returnValue(true)
32  );
33 
34  $synchronizerMock->expects($this->once())
35  ->method('synchronize');
36 
37  $cron = new SynchronizeWebsiteAttributes($synchronizerMock);
38  $cron->execute();
39  }
40 
42  {
43  $synchronizerMock = $this->getMockBuilder(WebsiteAttributesSynchronizer::class)
44  ->disableOriginalConstructor()
45  ->setMethods([
46  'isSynchronizationRequired',
47  'synchronize',
48  ])
49  ->getMock();
50 
51  $synchronizerMock->expects($this->once())
52  ->method('isSynchronizationRequired')
53  ->will(
54  $this->returnValue(false)
55  );
56 
57  $synchronizerMock->expects($this->never())
58  ->method('synchronize');
59 
60  $cron = new SynchronizeWebsiteAttributes($synchronizerMock);
61  $cron->execute();
62  }
63 }