/** * test method getValue * * @dataProvider getValueDataProvider */ public function testGetValue($specialPriceValue, $expectedResult) { $this->priceInfoMock->expects($this->once())->method('getPrices')->will($this->returnValue($this->prices)); $this->regularPriceMock->expects($this->exactly(3))->method('getValue')->will($this->returnValue(100)); $this->groupPriceMock->expects($this->exactly(2))->method('getValue')->will($this->returnValue(99)); $this->specialPriceMock->expects($this->any())->method('getValue')->will($this->returnValue($specialPriceValue)); $this->assertSame($expectedResult, $this->basePrice->getValue()); }
/** * test get group price, attribute is not set */ public function testGroupPriceAttributeIsNotSet() { $this->productMock->expects($this->exactly(2))->method('getCustomerGroupId')->will($this->returnValue(3)); $this->productMock->expects($this->once())->method('getResource')->will($this->returnValue($this->productResourceMock)); $this->productResourceMock->expects($this->once())->method('getAttribute')->with($this->equalTo('group_price'))->will($this->returnValue(null)); $this->assertFalse($this->groupPrice->getValue()); }
/** * Returns percent discount value * * @return bool|float */ public function getDiscountPercent() { if ($this->percent === null) { $percent = parent::getValue(); $this->percent = $percent ? max(0, min(100, 100 - $percent)) : null; } return $this->percent; }