fix tests
This commit is contained in:
@@ -347,7 +347,7 @@ class OrderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/* check tax */
|
||||
$orderProductTaxList = $orderProduct->getOrderProductTaxes();
|
||||
foreach ($cartItem->getProduct()->getTaxRule()->getTaxDetail($validDeliveryAddress->getCountry(), $cartItem->getPrice(), $cartItem->getPromoPrice()) as $index => $tax) {
|
||||
foreach ($cartItem->getProduct()->getTaxRule()->getTaxDetail($cartItem->getProduct(), $validDeliveryAddress->getCountry(), $cartItem->getPrice(), $cartItem->getPromoPrice()) as $index => $tax) {
|
||||
$orderProductTax = $orderProductTaxList[$index];
|
||||
$this->assertEquals($tax->getAmount(), $orderProductTax->getAmount());
|
||||
$this->assertEquals($tax->getPromoAmount(), $orderProductTax->getPromoAmount());
|
||||
|
||||
@@ -126,14 +126,64 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
|
||||
$aProduct = ProductQuery::create()->findOne();
|
||||
if(null === $aProduct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$product = $this->getProperty('product');
|
||||
$product->setValue($calculator, $aProduct);
|
||||
|
||||
$calculator->getTaxedPrice('foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Exception\TaxEngineException
|
||||
* @expectedExceptionCode 501
|
||||
*/
|
||||
public function testGetUntaxedPriceAndGetTaxAmountFromTaxedPriceWithNoProductLoaded()
|
||||
{
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
$taxRulesCollection->setModel('\Thelia\Model\Tax');
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$calculator->getTaxAmountFromTaxedPrice(600.95);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Exception\TaxEngineException
|
||||
* @expectedExceptionCode 507
|
||||
*/
|
||||
public function testGetUntaxedPriceAndGetTaxAmountFromTaxedPriceWithEmptyTaxRuleCollection()
|
||||
{
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
$taxRulesCollection->setModel('\Thelia\Model\Tax');
|
||||
|
||||
$aProduct = ProductQuery::create()->findOne();
|
||||
if(null === $aProduct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$product = $this->getProperty('product');
|
||||
$product->setValue($calculator, $aProduct);
|
||||
|
||||
$calculator->getTaxAmountFromTaxedPrice(600.95);
|
||||
}
|
||||
|
||||
public function testGetTaxedPriceAndGetTaxAmountFromUntaxedPrice()
|
||||
{
|
||||
$taxRulesCollection = new ObjectCollection();
|
||||
@@ -163,11 +213,19 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
->setVirtualColumn('taxRuleCountryPosition', 3);
|
||||
$taxRulesCollection->append($tax);
|
||||
|
||||
$aProduct = ProductQuery::create()->findOne();
|
||||
if(null === $aProduct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$product = $this->getProperty('product');
|
||||
$product->setValue($calculator, $aProduct);
|
||||
|
||||
$taxAmount = $calculator->getTaxAmountFromUntaxedPrice(500);
|
||||
$taxedPrice = $calculator->getTaxedPrice(500);
|
||||
|
||||
@@ -211,11 +269,19 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase
|
||||
->setVirtualColumn('taxRuleCountryPosition', 3);
|
||||
$taxRulesCollection->append($tax);
|
||||
|
||||
$aProduct = ProductQuery::create()->findOne();
|
||||
if(null === $aProduct) {
|
||||
return;
|
||||
}
|
||||
|
||||
$calculator = new Calculator();
|
||||
|
||||
$rewritingUrlQuery = $this->getProperty('taxRulesCollection');
|
||||
$rewritingUrlQuery->setValue($calculator, $taxRulesCollection);
|
||||
|
||||
$product = $this->getProperty('product');
|
||||
$product->setValue($calculator, $aProduct);
|
||||
|
||||
$taxAmount = $calculator->getTaxAmountFromTaxedPrice(600.95);
|
||||
$untaxedPrice = $calculator->getUntaxedPrice(600.95);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user