|
4 | 4 |
|
5 | 5 | class MangoTest extends PHPUnit_Framework_TestCase { |
6 | 6 |
|
7 | | - protected function setUp() { |
| 7 | + protected function setUp() { |
8 | 8 | $this->API_KEY = getenv("MANGO_SECRET_TEST_KEY"); |
9 | 9 | $this->PUBLIC_API_KEY = getenv("MANGO_PUBLIC_TEST_KEY"); |
10 | 10 |
|
@@ -280,6 +280,44 @@ public function testGetPromotion() { |
280 | 280 | $this->assertEquals($promotion->uid, $promotion_uid); |
281 | 281 | } |
282 | 282 |
|
| 283 | + |
| 284 | + /* Coupons */ |
| 285 | + public function testListCoupons(){ |
| 286 | + $coupons = $this->mango->Coupons->get_list(); |
| 287 | + $uid = $coupons[0]->uid; |
| 288 | + $this->assertTrue(strlen($uid) > 0); |
| 289 | + } |
| 290 | + |
| 291 | + public function testGetCoupon(){ |
| 292 | + $coupons = $this->mango->Coupons->get_list(); |
| 293 | + $coupon = $coupons[0]; |
| 294 | + $response = $this->mango->Coupons->get($coupon->uid); |
| 295 | + $this->assertEquals($response->uid, $coupon->uid); |
| 296 | + } |
| 297 | + |
| 298 | + public function testCreateCoupon() { |
| 299 | + date_default_timezone_set("America/Argentina/Buenos_Aires"); |
| 300 | + $coupon = $this->mango->Coupons->create(array( |
| 301 | + "amount" => 3000, |
| 302 | + "type" => "pagofacil", |
| 303 | + "first_due_date" => date("Y-m-d", mktime(0, 0, 0, date("m")+1, date("d"), date("Y"))), |
| 304 | + "second_due_date" => date("Y-m-d", mktime(0, 0, 0, date("m")+2, date("d"), date("Y"))), |
| 305 | + "surcharge" => 20 |
| 306 | + )); |
| 307 | + $this->assertTrue($coupon->amount == 3000); |
| 308 | + } |
| 309 | + |
| 310 | + public function testUpdateCoupon(){ |
| 311 | + $coupons = $this->mango->Coupons->get_list(); |
| 312 | + $coupon = $coupons[0]; |
| 313 | + $response = $this->mango->Coupons->update($coupon->uid, array( |
| 314 | + "paid" => true |
| 315 | + )); |
| 316 | + $this->assertEquals($response->uid, $coupon->uid); |
| 317 | + $this->assertTrue($response->paid == true); |
| 318 | + } |
| 319 | + |
| 320 | + |
283 | 321 | /* Api Keys */ |
284 | 322 | /** |
285 | 323 | * @expectedException Mango\InvalidApiKey |
|
0 commit comments