Exemplo n.º 1
0
 /**
  * @return array
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function attributeTypeDataProvider()
 {
     $htmlAttribute = new Attribute();
     $htmlAttribute->setContainHtml(true);
     $localizedAttribute = new Attribute();
     $localizedAttribute->setLocalized(true);
     $notLocalizedAttribute = new Attribute();
     $notLocalizedAttribute->setLocalized(false);
     return ['integer' => ['attributeType' => new Integer(), 'expected' => ['name' => Integer::NAME, 'typeField' => 'integer', 'isContainHtml' => false, 'isUsedForSearch' => false, 'isUsedInFilters' => true, 'formParameters' => ['type' => 'integer', 'options' => ['type' => 'text']], 'requiredConstraints' => [new IntegerConstraint()], 'optionalConstraints' => [new GreaterThanZero()], 'canBeUnique' => true, 'canBeRequired' => true]], 'boolean' => ['attributeType' => new Boolean(), 'expected' => ['name' => Boolean::NAME, 'typeField' => 'integer', 'isContainHtml' => false, 'isUsedForSearch' => false, 'isUsedInFilters' => true, 'formParameters' => ['type' => 'checkbox'], 'requiredConstraints' => [], 'optionalConstraints' => [], 'canBeUnique' => false, 'canBeRequired' => false], 'attribute' => null, 'normalizationData' => ['normalize' => [['from' => null, 'to' => null], ['from' => 0, 'to' => false], ['from' => 1, 'to' => true]], 'denormalize' => [['from' => null, 'to' => null], ['from' => '', 'to' => 0], ['from' => '0', 'to' => 0], ['from' => '1', 'to' => 1]]]], 'float' => ['attributeType' => new Float(), 'expected' => ['name' => Float::NAME, 'typeField' => 'float', 'isContainHtml' => false, 'isUsedForSearch' => false, 'isUsedInFilters' => true, 'formParameters' => ['type' => 'number'], 'requiredConstraints' => [new Decimal()], 'optionalConstraints' => [new GreaterThanZero(), new IntegerConstraint()], 'canBeUnique' => true, 'canBeRequired' => true]], 'string' => ['attributeType' => new String(), 'expected' => ['name' => String::NAME, 'typeField' => 'string', 'isContainHtml' => true, 'isUsedForSearch' => true, 'isUsedInFilters' => false, 'formParameters' => ['type' => 'text'], 'requiredConstraints' => [], 'optionalConstraints' => [new Letters(), new Alphanumeric(), new UrlSafe(), new Decimal(), new IntegerConstraint(), new Email(), new Url()], 'canBeUnique' => true, 'canBeRequired' => true]], 'text not localized' => ['attributeType' => new Text(), 'expected' => ['name' => Text::NAME, 'typeField' => 'text', 'isContainHtml' => true, 'isUsedForSearch' => true, 'isUsedInFilters' => false, 'formParameters' => ['type' => 'textarea'], 'requiredConstraints' => [], 'optionalConstraints' => [new Letters(), new Alphanumeric(), new UrlSafe(), new Decimal(), new IntegerConstraint(), new Email(), new Url()], 'canBeUnique' => true, 'canBeRequired' => true]], 'text localized' => ['attributeType' => new Text(), 'expected' => ['name' => Text::NAME, 'typeField' => 'text', 'isContainHtml' => true, 'isUsedForSearch' => true, 'isUsedInFilters' => false, 'formParameters' => ['type' => 'oro_rich_text'], 'requiredConstraints' => [], 'optionalConstraints' => [new Letters(), new Alphanumeric(), new UrlSafe(), new Decimal(), new IntegerConstraint(), new Email(), new Url()], 'canBeUnique' => true, 'canBeRequired' => true], 'attribute' => $htmlAttribute], 'date' => ['attributeType' => new Date(), 'expected' => ['name' => Date::NAME, 'typeField' => 'datetime', 'isContainHtml' => false, 'isUsedForSearch' => false, 'isUsedInFilters' => false, 'formParameters' => ['type' => 'oro_date'], 'requiredConstraints' => [], 'optionalConstraints' => [], 'canBeUnique' => true, 'canBeRequired' => true]], 'datetime' => ['attributeType' => new DateTime(), 'expected' => ['name' => DateTime::NAME, 'typeField' => 'datetime', 'isContainHtml' => false, 'isUsedForSearch' => false, 'isUsedInFilters' => false, 'formParameters' => ['type' => 'oro_datetime'], 'requiredConstraints' => [], 'optionalConstraints' => [], 'canBeUnique' => true, 'canBeRequired' => true]], 'select not localized' => ['attributeType' => new Select(), 'expected' => ['name' => Select::NAME, 'typeField' => 'options', 'isContainHtml' => false, 'isUsedForSearch' => true, 'isUsedInFilters' => true, 'formParameters' => ['type' => SelectAttributeTypeType::NAME], 'defaultFormParameters' => ['type' => NotLocalizedSelectCollectionType::NAME], 'requiredConstraints' => [], 'optionalConstraints' => [], 'canBeUnique' => false, 'canBeRequired' => true], 'attribute' => $notLocalizedAttribute], 'select localized' => ['attributeType' => new Select(), 'expected' => ['name' => Select::NAME, 'typeField' => 'options', 'isContainHtml' => false, 'isUsedForSearch' => true, 'isUsedInFilters' => true, 'formParameters' => ['type' => SelectAttributeTypeType::NAME], 'defaultFormParameters' => ['type' => LocalizedSelectCollectionType::NAME], 'requiredConstraints' => [], 'optionalConstraints' => [], 'canBeUnique' => false, 'canBeRequired' => true], 'attribute' => $localizedAttribute], 'multiselect not localized' => ['attributeType' => new MultiSelect(), 'expected' => ['name' => MultiSelect::NAME, 'typeField' => 'options', 'isContainHtml' => false, 'isUsedForSearch' => true, 'isUsedInFilters' => true, 'formParameters' => ['type' => MultiSelectAttributeTypeType::NAME], 'defaultFormParameters' => ['type' => NotLocalizedMultiselectCollectionType::NAME], 'requiredConstraints' => [], 'optionalConstraints' => [], 'canBeUnique' => false, 'canBeRequired' => true], 'attribute' => $notLocalizedAttribute], 'multiselect localized' => ['attributeType' => new MultiSelect(), 'expected' => ['name' => MultiSelect::NAME, 'typeField' => 'options', 'isContainHtml' => false, 'isUsedForSearch' => true, 'isUsedInFilters' => true, 'formParameters' => ['type' => MultiSelectAttributeTypeType::NAME], 'defaultFormParameters' => ['type' => LocalizedMultiselectCollectionType::NAME], 'requiredConstraints' => [], 'optionalConstraints' => [], 'canBeUnique' => false, 'canBeRequired' => true], 'attribute' => $localizedAttribute]];
 }