/** * Test is/setter for negativeAllowed property * * TODO : Test with the both values */ public function testIsSetNegativeAllowed() { $this->assertNull($this->attribute->isNegativeAllowed()); // Change value and assert new $this->assertEntity($this->attribute->setNegativeAllowed(false)); $this->assertFalse($this->attribute->isNegativeAllowed()); }
/** * {@inheritdoc} */ public function guessConstraints(AbstractAttribute $attribute) { $constraints = array(); if ('pim_catalog_date' === $attribute->getAttributeType()) { $min = $attribute->getDateMin(); $max = $attribute->getDateMax(); } else { $min = $attribute->getNumberMin(); $max = $attribute->getNumberMax(); if (false === $attribute->isNegativeAllowed() && ($min === null || $min < 0)) { $min = 0; } } if (null !== $min || null !== $max) { $constraints[] = new Range(array('min' => $min, 'max' => $max)); } return $constraints; }