Пример #1
0
 /**
  * @static
  * @param $row array
  * @return Attribute
  */
 public static function FromRow($row)
 {
     $attribute = new CustomAttribute($row[ColumnNames::ATTRIBUTE_ID], $row[ColumnNames::ATTRIBUTE_LABEL], $row[ColumnNames::ATTRIBUTE_TYPE], $row[ColumnNames::ATTRIBUTE_CATEGORY], $row[ColumnNames::ATTRIBUTE_CONSTRAINT], $row[ColumnNames::ATTRIBUTE_REQUIRED], $row[ColumnNames::ATTRIBUTE_POSSIBLE_VALUES], $row[ColumnNames::ATTRIBUTE_SORT_ORDER], $row[ColumnNames::ATTRIBUTE_ENTITY_ID], $row[ColumnNames::ATTRIBUTE_ENTITY_ID]);
     $attribute->WithEntityDescription($row[ColumnNames::ATTRIBUTE_ENTITY_DESCRIPTION]);
     return $attribute;
 }
 public function testLoadsAttributesByCategory()
 {
     $id = 12098;
     $label = 'label';
     $type = CustomAttributeTypes::SINGLE_LINE_TEXTBOX;
     $category = CustomAttributeCategory::RESERVATION;
     $regex = 'regex';
     $required = false;
     $possibleValues = 'val1,val2,val3';
     $sortOrder = '4';
     $entityId = 12;
     $entityDescription = 'entity desc';
     $row1 = $this->GetAttributeRow($id, $label, $type, $category, $regex, $required, $possibleValues, $sortOrder, $entityId, $entityDescription);
     $row2 = $this->GetAttributeRow(2);
     $this->db->SetRows(array($row1, $row2));
     $attributes = $this->repository->GetByCategory(CustomAttributeCategory::RESERVATION);
     $expectedFirstAttribute = new CustomAttribute($id, $label, $type, $category, $regex, $required, $possibleValues, $sortOrder, $entityId);
     $expectedFirstAttribute->WithEntityDescription($entityDescription);
     $this->assertEquals(2, count($attributes));
     $this->assertEquals($expectedFirstAttribute, $attributes[0]);
     $this->assertEquals(new GetAttributesByCategoryCommand(CustomAttributeCategory::RESERVATION), $this->db->_LastCommand);
 }