|
@@ 65-89 (lines=25) @@
|
| 62 |
|
* - controller will add a translated success message to the session. |
| 63 |
|
* - controller will attempt to redirect back to cart page when done. |
| 64 |
|
*/ |
| 65 |
|
public function testAddAction() |
| 66 |
|
{ |
| 67 |
|
$this->giftCard->expects($this->once()) |
| 68 |
|
->method('setPin') |
| 69 |
|
->with($this->identicalTo($this->giftCardPin)) |
| 70 |
|
->will($this->returnSelf()); |
| 71 |
|
$this->helper |
| 72 |
|
->expects($this->once()) |
| 73 |
|
->method('addGiftCardToOrder') |
| 74 |
|
->with($this->identicalTo($this->giftCard), $this->identicalTo($this->container)) |
| 75 |
|
->will($this->returnSelf()); |
| 76 |
|
$this->controller |
| 77 |
|
->expects($this->once()) |
| 78 |
|
->method('_redirect') |
| 79 |
|
->with($this->identicalTo(self::REDIRECT_PATH)) |
| 80 |
|
->willReturnSelf(); |
| 81 |
|
|
| 82 |
|
// inject the session mock |
| 83 |
|
$this->replaceByMock('singleton', 'checkout/session', $this->checkoutSession); |
| 84 |
|
$this->controller->addAction(); |
| 85 |
|
|
| 86 |
|
// Successfully adding gift card to order should result in success message |
| 87 |
|
// being added to checkout session. |
| 88 |
|
$this->assertCount(1, $this->checkoutSession->getMessages()->getItemsByType(Mage_Core_Model_Message::SUCCESS)); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
/** |
| 92 |
|
* verify: |
|
@@ 96-120 (lines=25) @@
|
| 93 |
|
* - when gift card cannot be added to the order, an error message is added |
| 94 |
|
* to the checkout session |
| 95 |
|
*/ |
| 96 |
|
public function testAddFail() |
| 97 |
|
{ |
| 98 |
|
$this->giftCard->expects($this->once()) |
| 99 |
|
->method('setPin') |
| 100 |
|
->with($this->identicalTo($this->giftCardPin)) |
| 101 |
|
->will($this->returnSelf()); |
| 102 |
|
$this->helper |
| 103 |
|
->expects($this->once()) |
| 104 |
|
->method('addGiftCardToOrder') |
| 105 |
|
->with($this->identicalTo($this->giftCard), $this->identicalTo($this->container)) |
| 106 |
|
->willThrowException(new EbayEnterprise_GiftCard_Exception('TEST EXCEPTION: ' . __METHOD__)); |
| 107 |
|
$this->controller |
| 108 |
|
->expects($this->once()) |
| 109 |
|
->method('_redirect') |
| 110 |
|
->with($this->identicalTo(self::REDIRECT_PATH)) |
| 111 |
|
->will($this->returnSelf()); |
| 112 |
|
|
| 113 |
|
// inject the session mock |
| 114 |
|
$this->replaceByMock('singleton', 'checkout/session', $this->checkoutSession); |
| 115 |
|
$this->controller->addAction(); |
| 116 |
|
|
| 117 |
|
// Failure to add gift card to the order should result in an error message |
| 118 |
|
// being added to the checkout session. |
| 119 |
|
$this->assertCount(1, $this->checkoutSession->getMessages()->getErrors()); |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
/** |
| 123 |
|
* verify: |