TC-DISC-09
Negative
changes data Overlapping of two promotions
Verify that two promotions cannot be active at the same time
! Documented discrepancy · errors.txt
All tests in this section: The discount tests are tricky because they involve persistent changes to the real data. To mitigate this problem and automate the tests, every discount is cancelled after the test. The ongoing promotion cannot be cancelled, and therefore have to be reused for these tests.
Specification · xlsx
Steps
- Set up a promotion
- Attempt another one in the same period
Expected result
The system rejects the request
Endpoints
POST · PUT · GET /payment/api/v1/merchant-integration/discountsPUT /payment/api/v1/merchant-integration/discounts/{id}/cancellations Run
- API_URL
https://api.qa2.ananastest.com- TARGET_ID
2555660- DISCOUNT_PRICE
10000
A dry run builds every request without sending it; responses come from a local stub.
Test code
mirrors tests/DiscountsTest.php::tc_disc_09()
206// Verify that two promotions cannot be active at the same time
207public function tc_disc_09(): void
208{
209 $targetId = (int) $_ENV['TARGET_ID'];
210
211 $responseOne = $this->ananas->setDiscounts([
212 'discounts' => [
213 [
214 'merchantInventoryId' => $targetId,
215 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
216 'discountPriceCurrency' => 'RSD',
217 'dateFrom' => Carbon::now()->addDays(10)->format('d/m/Y'),
218 'dateTo' => Carbon::now()->addDays(15)->format('d/m/Y'),
219 'discountType' => 'SALE',
220 ],
221 ],
222 ]);
223
224 $this->assertEquals(200, $responseOne['statusCode']);
225 $this->assertEquals(1, $responseOne['response']['scheduleResult'][0]['success']);
226
227 $discountId = $responseOne['response']['scheduleResult'][0]['data']['discountId'];
228
229 $responseTwo = $this->ananas->setDiscounts([
230 'discounts' => [
231 [
232 'merchantInventoryId' => $targetId,
233 'discountPrice' => (int) $_ENV['DISCOUNT_PRICE'],
234 'discountPriceCurrency' => 'RSD',
235 'dateFrom' => Carbon::now()->addDays(10)->format('d/m/Y'),
236 'dateTo' => Carbon::now()->addDays(20)->format('d/m/Y'),
237 'discountType' => 'SALE',
238 ],
239 ],
240 ]);
241
242 $this->assertEquals(200, $responseTwo['statusCode']);
243 $this->assertNotEquals(1, $responseTwo['response']['scheduleResult'][0]['success']);
244 $this->assertNotEmpty($responseTwo['response']['scheduleResult'][0]['error']);
245
246 $this->ananas->cancelDiscount($discountId);
247}
web/app/Scenarios/DiscountsScenarios.php · line numbers refer to this file
Not run yet. Run it against the API, or do a dry run to see the requests it would send.