Skip to content

Commit 7ccad23

Browse files
committed
ADO-313: updated phpunit for Meta_Promotion module
1 parent d4f4203 commit 7ccad23

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

app/code/Meta/Promotions/Test/Unit/Controller/Adminhtml/Ajax/PromotionFeedUploadTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,45 @@ public function testExecuteForJsonWithAccessToken()
154154

155155
$this->subject->executeForJson();
156156
}
157+
158+
public function testExecuteForJsonWithAccessTokenException()
159+
{
160+
$storeId = 1;
161+
$storeName = 'Default Store';
162+
$accessToken = 'akjfbkhab-afjhavfj-ahfhvgja';
163+
$pushFeedResponse = ['Success' => true];
164+
165+
$this->fbeHelperMock->expects($this->exactly(2))
166+
->method('getStore')
167+
->willReturn($this->storeMock);
168+
$this->storeMock->expects($this->once())
169+
->method('getId')
170+
->willReturn($storeId);
171+
$this->storeMock->expects($this->exactly(2))
172+
->method('getName')
173+
->willReturn($storeName);
174+
$this->requestMock->expects($this->once())
175+
->method('getParam')
176+
->with('store')
177+
->willReturn($storeId);
178+
$this->systemConfigMock->expects($this->once())
179+
->method('getStoreManager')
180+
->willReturn($this->storeManagerMock);
181+
$this->storeManagerMock->expects($this->once())
182+
->method('getStore')
183+
->with($storeId)
184+
->willReturn($this->storeMock);
185+
186+
$this->systemConfigMock->expects($this->once())
187+
->method('getAccessToken')
188+
->with($storeId)
189+
->willReturn($accessToken);
190+
191+
$this->uploaderMock->expects($this->once())
192+
->method('uploadPromotions')
193+
->with($storeId)
194+
->willThrowException(new \Exception('Unable to upload promotions.'));
195+
196+
$this->subject->executeForJson();
197+
}
157198
}

app/code/Meta/Promotions/Test/Unit/Cron/PromotionSyncCronTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,27 @@ public function testExecute(): void
6666

6767
$this->subject->execute();
6868
}
69+
70+
public function testExecuteException(): void
71+
{
72+
$storeId = 1;
73+
$uploadResponse = ['Success' => true];
74+
75+
$storeMock = $this->getMockBuilder(StoreInterface::class)
76+
->disableOriginalConstructor()
77+
->getMockForAbstractClass();
78+
79+
$this->systemConfigMock->expects($this->once())
80+
->method('getAllOnsiteFBEInstalledStores')
81+
->willReturn([$storeMock]);
82+
$storeMock->expects($this->exactly(2))
83+
->method('getId')
84+
->willReturn($storeId);
85+
$this->systemConfigMock->expects($this->once())
86+
->method('isPromotionsSyncEnabled')
87+
->with($storeId)
88+
->willThrowException(new \Exception('Unable to fetch data'));
89+
90+
$this->subject->execute();
91+
}
6992
}

0 commit comments

Comments
 (0)