|
@@ 53-78 (lines=26) @@
|
| 50 |
|
* the container by card number, have the PIN set on the card and finally |
| 51 |
|
* be added to the order. |
| 52 |
|
*/ |
| 53 |
|
public function testAddGiftCard() |
| 54 |
|
{ |
| 55 |
|
$cardNumber = '1111111111111111'; |
| 56 |
|
$pin = '1234'; |
| 57 |
|
|
| 58 |
|
$this->container |
| 59 |
|
->method('getGiftCard') |
| 60 |
|
->with($cardNumber) |
| 61 |
|
->willReturn($this->giftCard); |
| 62 |
|
// Pin must be set on the gift card to be added. |
| 63 |
|
$this->giftCard->expects($this->once()) |
| 64 |
|
->method('setPin') |
| 65 |
|
->with($this->identicalTo($pin)) |
| 66 |
|
->willReturnSelf(); |
| 67 |
|
// Helper should be used to add the gift card to the order. Expect |
| 68 |
|
// it to be successful in this case. |
| 69 |
|
$this->helper->expects($this->once()) |
| 70 |
|
->method('addGiftCardToOrder') |
| 71 |
|
->with($this->identicalTo($this->giftCard), $this->identicalTo($this->container)) |
| 72 |
|
->willReturnSelf(); |
| 73 |
|
|
| 74 |
|
$this->assertSame( |
| 75 |
|
$this->observer, |
| 76 |
|
EcomDev_Utils_Reflection::invokeRestrictedMethod($this->observer, 'addGiftCard', [$cardNumber, $pin]) |
| 77 |
|
); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
/** |
| 81 |
|
* Failing to add a gift card to cart should fail silently. |
|
@@ 83-108 (lines=26) @@
|
| 80 |
|
/** |
| 81 |
|
* Failing to add a gift card to cart should fail silently. |
| 82 |
|
*/ |
| 83 |
|
public function testAddGiftCardException() |
| 84 |
|
{ |
| 85 |
|
$cardNumber = '1111111111111111'; |
| 86 |
|
$pin = '1234'; |
| 87 |
|
|
| 88 |
|
$this->container |
| 89 |
|
->method('getGiftCard') |
| 90 |
|
->with($cardNumber) |
| 91 |
|
->willReturn($this->giftCard); |
| 92 |
|
// Pin must be set on the gift card to be added. |
| 93 |
|
$this->giftCard->expects($this->once()) |
| 94 |
|
->method('setPin') |
| 95 |
|
->with($this->identicalTo($pin)) |
| 96 |
|
->willReturnSelf(); |
| 97 |
|
// When gift card cannot be added to cart, the helper will throw an |
| 98 |
|
// exception indicating the failure. |
| 99 |
|
$this->helper->expects($this->once()) |
| 100 |
|
->method('addGiftCardToOrder') |
| 101 |
|
->with($this->identicalTo($this->giftCard), $this->identicalTo($this->container)) |
| 102 |
|
->willThrowException(new EbayEnterprise_GiftCard_Exception('TEST EXCEPTION: ' . __METHOD__)); |
| 103 |
|
|
| 104 |
|
$this->assertSame( |
| 105 |
|
$this->observer, |
| 106 |
|
EcomDev_Utils_Reflection::invokeRestrictedMethod($this->observer, 'addGiftCard', [$cardNumber, $pin]) |
| 107 |
|
); |
| 108 |
|
} |
| 109 |
|
} |
| 110 |
|
|