mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-04 06:04:16 +09:00
Re-check promo code validity during checkout (#1316)
* Re-check promo code validity during checkout * Add tools mock to the failing test * Properly resolve issue with the tests
This commit is contained in:
1 parent
b65a75fcf7
commit
a02b1b32fe
2 files changed
+11
-2
No files matched your search
@@ -424,6 +424,14 @@ class Service implements InjectionAwareInterface
|
||||
if (!$this->isClientAbleToUsePromo($client, $promo)) {
|
||||
throw new \Box_Exception('You have already used this promo code. Please remove promo code and checkout again.', null, 9874);
|
||||
}
|
||||
|
||||
if (!$promo instanceof \Model_Promo) {
|
||||
throw new \Box_Exception('Promo code is expired or does not exist');
|
||||
}
|
||||
|
||||
if (!$this->isPromoAvailableForClientGroup($promo)) {
|
||||
throw new \Box_Exception('Promo can not be applied to your account');
|
||||
}
|
||||
}
|
||||
|
||||
$this->di['events_manager']->fire(
|
||||
|
||||
@@ -654,13 +654,15 @@ class ServiceTest extends \BBTestCase
|
||||
$order->loadBean(new \DummyBean());
|
||||
|
||||
$serviceMock = $this->getMockBuilder('\Box\Mod\Cart\Service')
|
||||
->setMethods(array('createFromCart', 'isClientAbleToUsePromo', 'rm'))->getMock();
|
||||
->setMethods(array('createFromCart', 'isClientAbleToUsePromo', 'rm', 'isPromoAvailableForClientGroup'))->getMock();
|
||||
$serviceMock->expects($this->atLeastOnce())->method('createFromCart')
|
||||
->will($this->returnValue(array($order, rand(1, 100), array(rand(1, 100)))));
|
||||
$serviceMock->expects($this->atLeastOnce())->method('isClientAbleToUsePromo')
|
||||
->will($this->returnValue(true));
|
||||
$serviceMock->expects($this->atLeastOnce())->method('rm')
|
||||
->will($this->returnValue(true));
|
||||
$serviceMock->expects($this->atLeastOnce())->method('isPromoAvailableForClientGroup')
|
||||
->will($this->returnValue(true));
|
||||
|
||||
$eventMock = $this->getMockBuilder('\Box_EventManager')->getMock();
|
||||
$eventMock->expects($this->atLeastOnce())->method('fire');
|
||||
@@ -671,7 +673,6 @@ class ServiceTest extends \BBTestCase
|
||||
->method('getClientAddress')
|
||||
->will($this->returnValue('1.1.1.1'));
|
||||
|
||||
|
||||
$invoice = new \Model_Invoice();
|
||||
$invoice->loadBean(new \DummyBean());
|
||||
$invoice->hash = sha1('str');
|
||||
|
||||
Reference in new issue
Block a user