Example #1
0
 public function testFloatType()
 {
     $floatType = new FloatType();
     $this->assertTrue($floatType->isValid('1.1'));
     $this->assertTrue($floatType->isValid(2.2));
     $this->assertFalse($floatType->isValid('foo'));
 }
 public function fixAmountRetriever(Product $product)
 {
     $taxAmount = 0;
     $featureId = $this->getRequirement("feature");
     $query = FeatureProductQuery::create()->filterByProduct($product)->filterByFeatureId($featureId)->findOne();
     if (null !== $query) {
         $taxAmount = $query->getFreeTextValue();
         $testInt = new FloatType();
         if (!$testInt->isValid($taxAmount)) {
             throw new TaxEngineException(Translator::getInstance()->trans('Feature value does not match FLOAT format'), TaxEngineException::FEATURE_BAD_EXPECTED_VALUE);
         }
     }
     return $taxAmount;
 }
Example #3
0
 /**
  * Check if price is valid
  *
  * @param float $priceValue Price value to check
  *
  * @return bool
  * @throws \Thelia\Exception\InvalidConditionValueException
  */
 protected function isPriceValid($priceValue)
 {
     $floatType = new FloatType();
     if (!$floatType->isValid($priceValue) || $priceValue <= 0) {
         throw new InvalidConditionValueException(get_class(), 'price');
     }
     return true;
 }