/** * Test getter/setter for maxFileSize property */ public function testGetSetMaxFileSize() { $this->assertNull($this->attribute->getMaxFileSize()); // Change value and assert new $size = 1.23; $this->assertEntity($this->attribute->setMaxFileSize($size)); $this->assertEquals($size, $this->attribute->getMaxFileSize()); }
/** * {@inheritdoc} */ public function guessConstraints(AbstractAttribute $attribute) { $constraints = array(); $options = array(); if ($maxSize = $attribute->getMaxFileSize()) { if ($maxSize == (int) $maxSize) { $maxSize = (int) $maxSize; $unit = self::MEGABYTE_UNIT; } else { $maxSize = intval($maxSize * self::KILOBYTE_MULTIPLIER); $unit = self::KILOBYTE_UNIT; } $options['maxSize'] = sprintf('%d%s', $maxSize, $unit); } if ($allowedExtensions = $attribute->getAllowedExtensions()) { $options['allowedExtensions'] = $allowedExtensions; } if ($options) { $constraints[] = new File($options); } return $constraints; }