/** * @depends testAddPropertyAddsProperty */ public function testAddPropertiesAddsAListOfProperties() { $properties = new Properties(); $stringProperty = new PropertyString('stringProp', 'stringPropValue'); $properties->addProperty($stringProperty); $stringProperty2 = new PropertyString('stringProp2', 'stringPropValue2'); $stringProperty3 = new PropertyString('stringProp3', 'stringPropValue3'); $properties->addProperties(array($stringProperty2, $stringProperty3)); $this->assertAttributeSame(array($stringProperty->getId() => $stringProperty, $stringProperty2->getId() => $stringProperty2, $stringProperty3->getId() => $stringProperty3), 'properties', $properties); }
/** * @dataProvider stringCastDataProvider * @param string $expected * @param mixed $value */ public function testSetValueSetsValuesProperty($expected, $value) { if ($value === null) { $expected = null; } if (!is_string($value) && $value !== null) { $this->setExpectedException('\\Dkd\\PhpCmis\\Exception\\CmisInvalidArgumentException', null, 1413440336); } $this->subjectUnderTest->setValue($value); $this->assertAttributeSame(array($expected), 'values', $this->subjectUnderTest); }
/** * {@inheritdoc} * * @param string[] $values */ public function setValues(array $values) { // currently no special behavior here. It's just a string value. parent::setValues($values); }
/** * @covers Dkd\PhpCmis\Converter\JsonConverter::convertProperties * @covers Dkd\PhpCmis\Converter\JsonConverter::getPropertyByPropertyType * @covers Dkd\PhpCmis\Converter\JsonConverter::convertStringValues * @covers Dkd\PhpCmis\Converter\JsonConverter::convertBooleanValues * @covers Dkd\PhpCmis\Converter\JsonConverter::convertIntegerValues * @covers Dkd\PhpCmis\Converter\JsonConverter::convertDecimalValues * @return Properties */ public function testConvertPropertiesConvertsArrayToPropertiesObject() { $properties = new Properties(); $htmlProperty = new PropertyHtml('HtmlProp', 'dummy value'); $htmlProperty->setLocalName('HtmlProp'); $htmlProperty->setQueryName('HtmlProp'); $htmlProperty->setDisplayName('Sample Html Property'); $properties->addProperty($htmlProperty); $idProperty = new PropertyId('IdProp', 'dummy value'); $idProperty->setLocalName('IdProp'); $idProperty->setQueryName('IdProp'); $idProperty->setDisplayName('Sample Id Property'); $properties->addProperty($idProperty); $dateTimeMultiValueProperty = new PropertyDateTime('DateTimePropMV', array(new \DateTime('@1342160128'), new \DateTime('@1342170128'))); $dateTimeMultiValueProperty->setLocalName('DateTimePropMV'); $dateTimeMultiValueProperty->setQueryName('DateTimePropMV'); $dateTimeMultiValueProperty->setDisplayName('Sample DateTime multi-value Property'); $properties->addProperty($dateTimeMultiValueProperty); $uriProperty = new PropertyUri('UriProp', 'dummy value'); $uriProperty->setLocalName('UriProp'); $uriProperty->setQueryName('UriProp'); $uriProperty->setDisplayName('Sample Uri Property'); $properties->addProperty($uriProperty); $decimalProperty = new PropertyDecimal('DecimalProp', 1.2); $decimalProperty->setLocalName('DecimalProp'); $decimalProperty->setQueryName('DecimalProp'); $decimalProperty->setDisplayName('Sample Decimal Property'); $properties->addProperty($decimalProperty); $uriMultiValueProperty = new PropertyUri('UriPropMV', array('dummy value', 'dummy value')); $uriMultiValueProperty->setLocalName('UriPropMV'); $uriMultiValueProperty->setQueryName('UriPropMV'); $uriMultiValueProperty->setDisplayName('Sample Uri multi-value Property'); $properties->addProperty($uriMultiValueProperty); $booleanProperty = new PropertyBoolean('BooleanProp', true); $booleanProperty->setLocalName('BooleanProp'); $booleanProperty->setQueryName('BooleanProp'); $booleanProperty->setDisplayName('Sample Boolean Property'); $properties->addProperty($booleanProperty); $idMultiValueProperty = new PropertyId('IdPropMV', array('dummy value', 'dummy value')); $idMultiValueProperty->setLocalName('IdPropMV'); $idMultiValueProperty->setQueryName('IdPropMV'); $idMultiValueProperty->setDisplayName('Sample Id Html multi-value Property'); $properties->addProperty($idMultiValueProperty); $pickListProperty = new PropertyString('PickListProp', 'blue'); $pickListProperty->setLocalName('PickListProp'); $pickListProperty->setQueryName('PickListProp'); $pickListProperty->setDisplayName('Sample Pick List Property'); $properties->addProperty($pickListProperty); $htmlMultiValueProperty = new PropertyHtml('HtmlPropMV', array('dummy value', 'dummy value')); $htmlMultiValueProperty->setLocalName('HtmlPropMV'); $htmlMultiValueProperty->setQueryName('HtmlPropMV'); $htmlMultiValueProperty->setDisplayName('Sample Html multi-value Property'); $properties->addProperty($htmlMultiValueProperty); $intProperty = new PropertyInteger('IntProp', 12); $intProperty->setLocalName('IntProp'); $intProperty->setQueryName('IntProp'); $intProperty->setDisplayName('Sample Int Property'); $properties->addProperty($intProperty); $stringProperty = new PropertyString('StringProp', 'My Doc StringProperty 18'); $stringProperty->setLocalName('StringProp'); $stringProperty->setQueryName('StringProp'); $stringProperty->setDisplayName('Sample String Property'); $properties->addProperty($stringProperty); $decimalMultiValueProperty = new PropertyDecimal('DecimalPropMV', array(1.2, 2.3)); $decimalMultiValueProperty->setLocalName('DecimalPropMV'); $decimalMultiValueProperty->setQueryName('DecimalPropMV'); $decimalMultiValueProperty->setDisplayName('Sample Decimal multi-value Property'); $properties->addProperty($decimalMultiValueProperty); $dateTimeProperty = new PropertyDateTime('DateTimeProp', new \DateTime('@1342160128')); $dateTimeProperty->setLocalName('DateTimeProp'); $dateTimeProperty->setQueryName('DateTimeProp'); $dateTimeProperty->setDisplayName('Sample DateTime Property'); $properties->addProperty($dateTimeProperty); $booleanMultiValueProperty = new PropertyBoolean('BooleanPropMV', array(true, false)); $booleanMultiValueProperty->setLocalName('BooleanPropMV'); $booleanMultiValueProperty->setQueryName('BooleanPropMV'); $booleanMultiValueProperty->setDisplayName('Sample Boolean multi-value Property'); $properties->addProperty($booleanMultiValueProperty); $intMultiValueProperty = new PropertyInteger('IntPropMV', array(1, 2)); $intMultiValueProperty->setLocalName('IntPropMV'); $intMultiValueProperty->setQueryName('IntPropMV'); $intMultiValueProperty->setDisplayName('Sample Int multi-value Property'); $properties->addProperty($intMultiValueProperty); $properties->setExtensions($this->cmisExtensionsDummy); $getObjectResponse = $this->getResponseFixtureContentAsArray('Cmis/v1.1/BrowserBinding/getObject-response.log'); $result = $this->jsonConverter->convertProperties($getObjectResponse[JSONConstants::JSON_OBJECT_PROPERTIES], $getObjectResponse[JSONConstants::JSON_OBJECT_PROPERTIES_EXTENSION]); $this->assertEquals($properties, $result); return $result; }
public function testGetPropertyValueByQueryNameReturnsFirstPropertyValueFromSelectedProperty() { $sessionMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\SessionInterface')->setMethods(array('getObjectFactory', 'getDefaultContext'))->getMockForAbstractClass(); $objectFactory = new ObjectFactory(); $objectFactory->initialize($sessionMock); $operationContext = new OperationContext(); $sessionMock->expects($this->once())->method('getObjectFactory')->willReturn($objectFactory); $sessionMock->expects($this->any())->method('getDefaultContext')->willReturn($operationContext); $values1 = array('foobar', 'barbaz', 'foobaz'); $property1 = new PropertyString('foo', $values1); $property1->setQueryName('baz:foo'); $values2 = array(123, 234, 345); $property2 = new PropertyInteger('bar', $values2); $property2->setQueryName('baz:bar'); $properties = new Properties(); $properties->addProperties(array($property1, $property2)); $objectData = new ObjectData(); $objectData->setProperties($properties); $queryResult = new QueryResult($sessionMock, $objectData); $this->assertEquals('foobar', $queryResult->getPropertyValueByQueryName('baz:foo')); $this->assertEquals(123, $queryResult->getPropertyValueByQueryName('baz:bar')); $this->assertEquals(null, $queryResult->getPropertyValueByQueryName('not:exists')); }