/** * @dataProvider testGetCartProductTitleProvider */ public function testGetCartProductTitle($data, $expected) { $product = new \Model_CartProduct(); $product->loadBean(new \RedBeanPHP\OODBBean()); $product->title = "Example.com Registration"; $result = $this->service->getCartProductTitle($product, $data); $this->assertEquals($result, $expected); }
public function testgetProductDiscount_ProductQtyIsSetAndFreeSetup() { $cartProductModel = new \Model_CartProduct(); $cartProductModel->loadBean(new \RedBeanPHP\OODBBean()); $modelCart = new \Model_Cart(); $modelCart->loadBean(new \RedBeanPHP\OODBBean()); $modelCart->promo_id = 1; $promoModel = new \Model_Promo(); $promoModel->loadBean(new \RedBeanPHP\OODBBean()); $promoModel->freesetup = 1; $discountPrice = 25; $dbMock = $this->getMockBuilder('\\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce())->method('load')->with('Cart')->willReturn($modelCart); $dbMock->expects($this->atLeastOnce())->method('getExistingModelById')->with('Promo')->willReturn($promoModel); $di = new \Box_Di(); $di['db'] = $dbMock; $serviceMock = $this->getMockBuilder('\\Box\\Mod\\Cart\\Service')->setMethods(array('getRelatedItemsDiscount', 'getItemPromoDiscount', 'getItemConfig'))->getMock(); $serviceMock->expects($this->atLeastOnce())->method('getRelatedItemsDiscount')->willReturn(0); $serviceMock->expects($this->atLeastOnce())->method('getItemPromoDiscount')->willReturn($discountPrice); $serviceMock->setDi($di); $setupPrice = 25; $result = $serviceMock->getProductDiscount($cartProductModel, $setupPrice); $this->assertInternalType('array', $result); $this->assertEquals($discountPrice, $result[0]); $discountSetup = $setupPrice; $this->assertEquals($discountSetup, $result[1]); }