Ejemplo n.º 1
0
 public function testGetValue()
 {
     $this->priceInfoMock->expects($this->once())->method('getPrice')->with($this->equalTo('regular_price'))->will($this->returnValue($this->regularPrice));
     $this->regularPrice->expects($this->once())->method('getValue')->will($this->returnValue(100));
     $this->productMock->expects($this->once())->method('getCustomerGroupId')->will($this->returnValue(null));
     $this->customerSessionMock->expects($this->once())->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($this->attributeMock));
     $this->attributeMock->expects($this->once())->method('getBackend')->will($this->returnValue($this->backendMock));
     $this->backendMock->expects($this->once())->method('afterLoad')->with($this->equalTo($this->productMock))->will($this->returnValue($this->backendMock));
     $this->priceCurrencyMock->expects($this->never())->method('convertAndRound');
     $this->productMock->expects($this->once())->method('getData')->with($this->equalTo('group_price'), $this->equalTo(null))->will($this->returnValue([['cust_group' => 3, 'website_price' => 80]]));
     $this->assertEquals(20, $this->groupPrice->getValue());
     $this->assertEquals(20, $this->groupPrice->getValue());
 }
Ejemplo n.º 2
0
 /**
  * test get group price, customer group in session
  */
 public function testGroupPriceCustomerGroupInProduct()
 {
     $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($this->attributeMock));
     $this->attributeMock->expects($this->once())->method('getBackend')->will($this->returnValue($this->backendMock));
     $this->backendMock->expects($this->once())->method('afterLoad')->with($this->equalTo($this->productMock))->will($this->returnValue($this->backendMock));
     $this->productMock->expects($this->once())->method('getData')->with($this->equalTo('group_price'), $this->equalTo(null))->will($this->returnValue([['cust_group' => 3, 'website_price' => 80]]));
     $this->assertEquals(80, $this->groupPrice->getValue());
 }
Ejemplo n.º 3
0
 /**
  * test get group price, customer group in session
  *
  * @param int $customerGroup
  * @dataProvider dataProviderGroupPriceCustomerGroupInProduct
  */
 public function testGroupPriceCustomerGroupInProduct($customerGroup)
 {
     $groupPrice = 80;
     $convertedPrice = 56.23;
     $this->productMock->expects($this->exactly(2))->method('getCustomerGroupId')->will($this->returnValue($customerGroup));
     $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($this->attributeMock));
     $this->attributeMock->expects($this->once())->method('getBackend')->will($this->returnValue($this->backendMock));
     $this->backendMock->expects($this->once())->method('afterLoad')->with($this->equalTo($this->productMock))->will($this->returnValue($this->backendMock));
     $this->productMock->expects($this->once())->method('getData')->with($this->equalTo('group_price'), $this->equalTo(null))->will($this->returnValue([['cust_group' => $customerGroup, 'website_price' => $groupPrice]]));
     $this->priceCurrencyMock->expects($this->once())->method('convertAndRound')->with($groupPrice)->will($this->returnValue($convertedPrice));
     $this->assertEquals($convertedPrice, $this->groupPrice->getValue());
 }