fix tests

This commit is contained in:
Etienne Roudeix
2013-10-07 14:36:20 +02:00
parent fe3aea4ab7
commit b84e863033
14 changed files with 306 additions and 46 deletions

View File

@@ -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);