Commit 2200d216 authored by Karamel's avatar Karamel
Browse files

Add SCALE_TYPE_TIME (value = 3) for product scaleType

parent ebcbc782
......@@ -168,6 +168,8 @@ class Product extends DoctrineMainModel
const SCALE_TYPE_WEIGHT = 1;
/** Constant for scaleType, product is referenced by volume (mapped to 2). */
const SCALE_TYPE_VOLUME = 2;
/** Constant for scaleType, product is referenced by time (mapped to 3). */
const SCALE_TYPE_TIME = 3;
/**
* See SCALE_TYPE_* constants.
* Used to compute reference prices like price per liter or kg.
......@@ -180,7 +182,8 @@ class Product extends DoctrineMainModel
public function setScaleType($type) {
if ($type != Product::SCALE_TYPE_NONE
&& $type != Product::SCALE_TYPE_WEIGHT
&& $type != Product::SCALE_TYPE_VOLUME) {
&& $type != Product::SCALE_TYPE_VOLUME
&& $type != Product::SCALE_TYPE_TIME) {
throw new \InvalidArgumentException('Unknown scaleType');
}
$this->scaleType = $type;
......
......@@ -65,6 +65,20 @@ class ProductTest extends TestCase
$this->dao->close();
}
public function testSetScaleType() {
$prd = new Product();
$prd->setScaleType(Product::SCALE_TYPE_VOLUME);
$this->assertEquals(Product::SCALE_TYPE_VOLUME, $prd->getScaleType());
$exceptionThrown = false;
try {
$prd->setScaleType(99);
} catch (\InvalidArgumentException $e) {
$exceptionThrown = true;
$this->assertEquals('Unknown scaleType', $e->getMessage());
}
$this->assertTrue($exceptionThrown, 'Exception not thrown');
}
public function testGetTaxedPrice() {
$prd = new Product();
$prd->setReference('prd');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment