public function objectPropertyDataProvider() { $propertyType = PropertyType::cast(PropertyType::ID); $cardinality = Cardinality::cast(Cardinality::MULTI); $updatability = Updatability::cast(Updatability::ONCREATE); $choices = array($this->getMockBuilder('\\Dkd\\PhpCmis\\Definitions\\ChoiceInterface')->getMockForAbstractClass()); return array(array('propertyType', $propertyType, $propertyType), array('cardinality', $cardinality, $cardinality), array('updatability', $updatability, $updatability), array('choices', $choices, $choices)); }
$integer->setPropertyType(\Dkd\PhpCmis\Enum\PropertyType::cast(\Dkd\PhpCmis\Enum\PropertyType::INTEGER)); $integer->setLocalName('cmis:integerValue'); $integer->setQueryName('cmis:integerValue'); $integer->setIsInherited(true); $integer->setIsOpenChoice(true); $integer->setIsOrderable(false); $integer->setDescription('This is a integer property.'); $integer->setUpdatability(\Dkd\PhpCmis\Enum\Updatability::cast(\Dkd\PhpCmis\Enum\Updatability::READWRITE)); $integer->setLocalNamespace('namespace'); $integer->setDisplayName('Integer property'); $integer->setIsRequired(false); $integer->setCardinality(\Dkd\PhpCmis\Enum\Cardinality::cast(\Dkd\PhpCmis\Enum\Cardinality::MULTI)); $integer->setIsQueryable(true); $integer->setMinValue(5); $integer->setMaxValue(100); $datetime = new \Dkd\PhpCmis\DataObjects\PropertyDateTimeDefinition('cmis:datetime'); $datetime->setPropertyType(\Dkd\PhpCmis\Enum\PropertyType::cast(\Dkd\PhpCmis\Enum\PropertyType::DATETIME)); $datetime->setLocalName('cmis:datetimeValue'); $datetime->setQueryName('cmis:datetimeValue'); $datetime->setIsInherited(true); $datetime->setIsOpenChoice(true); $datetime->setIsOrderable(false); $datetime->setDescription('This is a datetime property.'); $datetime->setUpdatability(\Dkd\PhpCmis\Enum\Updatability::cast(\Dkd\PhpCmis\Enum\Updatability::READWRITE)); $datetime->setLocalNamespace('namespace'); $datetime->setDisplayName('Datetime property'); $datetime->setIsRequired(false); $datetime->setCardinality(\Dkd\PhpCmis\Enum\Cardinality::cast(\Dkd\PhpCmis\Enum\Cardinality::MULTI)); $datetime->setIsQueryable(true); $datetime->setDateTimeResolution(\Dkd\PhpCmis\Enum\DateTimeResolution::cast(\Dkd\PhpCmis\Enum\DateTimeResolution::TIME)); return array('cmis:id' => $id, 'cmis:string' => $string, 'cmis:boolean' => $boolean, 'cmis:uri' => $uri, 'cmis:decimal' => $decimal, 'cmis:html' => $html, 'cmis:integer' => $integer, 'cmis:datetime' => $datetime);
public function testPreparePropertyDefinitionDataConvertsValuesToExpectedValues() { $input = array(JSONConstants::JSON_PROPERTY_TYPE_PROPERTY_TYPE => 'boolean', JSONConstants::JSON_PROPERTY_TYPE_DEAULT_VALUE => true, JSONConstants::JSON_PROPERTY_TYPE_RESOLUTION => 'date', JSONConstants::JSON_PROPERTY_TYPE_PRECISION => '32', JSONConstants::JSON_PROPERTY_TYPE_CARDINALITY => 'single', JSONConstants::JSON_PROPERTY_TYPE_UPDATABILITY => 'readonly'); $expected = array(JSONConstants::JSON_PROPERTY_TYPE_PROPERTY_TYPE => PropertyType::cast('boolean'), JSONConstants::JSON_PROPERTY_TYPE_DEAULT_VALUE => array(true), JSONConstants::JSON_PROPERTY_TYPE_RESOLUTION => DateTimeResolution::cast('date'), JSONConstants::JSON_PROPERTY_TYPE_PRECISION => DecimalPrecision::cast('32'), JSONConstants::JSON_PROPERTY_TYPE_CARDINALITY => Cardinality::cast('single'), JSONConstants::JSON_PROPERTY_TYPE_UPDATABILITY => Updatability::cast('readonly')); $this->assertEquals($expected, $this->getMethod(self::CLASS_TO_TEST, 'preparePropertyDefinitionData')->invokeArgs($this->jsonConverter, array($input))); }
/** * @depends testSetCanCreateSetsProperty */ public function testCanCreateReturnsProperty() { $types = array(PropertyType::cast(PropertyType::DATETIME)); $this->creatablePropertyTypes->setCanCreate($types); $this->assertSame($types, $this->creatablePropertyTypes->canCreate()); }
/** * @param PropertyType $propertyType * @param string $id * @param array $propertyValues * @return PropertyBoolean|PropertyDateTime|PropertyDecimal|PropertyHtml|PropertyId|PropertyInteger|PropertyString */ protected function getPropertyByPropertyType(PropertyType $propertyType, $id, array $propertyValues) { if ($propertyType->equals(PropertyType::cast(PropertyType::STRING))) { $property = new PropertyString($id, $this->convertStringValues($propertyValues)); } elseif ($propertyType->equals(PropertyType::cast(PropertyType::ID))) { $property = new PropertyId($id, $this->convertStringValues($propertyValues)); } elseif ($propertyType->equals(PropertyType::cast(PropertyType::BOOLEAN))) { $property = new PropertyBoolean($id, $this->convertBooleanValues($propertyValues)); } elseif ($propertyType->equals(PropertyType::cast(PropertyType::INTEGER))) { $property = new PropertyInteger($id, $this->convertIntegerValues($propertyValues)); } elseif ($propertyType->equals(PropertyType::cast(PropertyType::DATETIME))) { $property = new PropertyDateTime($id, $this->convertDateTimeValues($propertyValues)); } elseif ($propertyType->equals(PropertyType::cast(PropertyType::DECIMAL))) { $property = new PropertyDecimal($id, $this->convertDecimalValues($propertyValues)); } elseif ($propertyType->equals(PropertyType::cast(PropertyType::HTML))) { $property = new PropertyHtml($id, $this->convertStringValues($propertyValues)); } elseif ($propertyType->equals(PropertyType::cast(PropertyType::URI))) { $property = new PropertyUri($id, $this->convertStringValues($propertyValues)); } else { // this could only happen if a new property type is added to the enumeration and not implemented here. throw new CmisInvalidArgumentException(sprintf('The given property type "%s" could not be converted.', $propertyType)); } return $property; }