/** * @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); }
public function testConvertPropertiesToQueryArrayConvertsPropertiesIntoAnArray() { $sessionMock = $this->getSessionMock(); /** @var PHPUnit_Framework_MockObject_MockObject|AbstractBrowserBindingService $binding */ $binding = $this->getMockBuilder(self::CLASS_TO_TEST)->setConstructorArgs(array($sessionMock))->getMockForAbstractClass(); $properties = new Properties(); $currentTime = new \DateTime('now'); $singleValueStringProperty = new PropertyString('stringProp', 'stringValue'); $multiValueStringProperty = new PropertyString('stringProp2', array('stringValue1', 'stringValue2')); $singleValueBooleanProperty = new PropertyBoolean('booleanProp', true); $singleValueDecimalProperty = new PropertyDecimal('decimalProp', 1.2); $singleValueDateTimeProperty = new PropertyDateTime('dateTimeProp', $currentTime); $singleValueIdProperty = new PropertyId('idProp', 'idValue'); $properties->addProperties(array($singleValueStringProperty, $multiValueStringProperty, $singleValueBooleanProperty, $singleValueDecimalProperty, $singleValueDateTimeProperty, $singleValueIdProperty)); $expectedArray = array(Constants::CONTROL_PROP_ID => array(0 => 'stringProp', 1 => 'stringProp2', 2 => 'booleanProp', 3 => 'decimalProp', 4 => 'dateTimeProp', 5 => 'idProp'), Constants::CONTROL_PROP_VALUE => array(0 => 'stringValue', 1 => array(0 => 'stringValue1', 1 => 'stringValue2'), 2 => true, 3 => 1.2, 4 => $currentTime->getTimestamp() * 1000, 5 => 'idValue')); $this->assertEquals($expectedArray, $this->getMethod(self::CLASS_TO_TEST, 'convertPropertiesToQueryArray')->invokeArgs($binding, array($properties))); }
/** * Data provider for updateProperties * * @return array */ public function updatePropertiesDataProvider() { $propertySet1 = new Properties(); $propertySet1->addProperties(array(new PropertyString('cmis:name', 'name'), new PropertyString('cmis:description', 'description'))); $propertySet2 = new Properties(); $propertySet2->addProperties(array(new PropertyString('cmis:name', 'foo'), new PropertyString('cmis:description', 'bar'))); return array('Parameter set with defined changeToken and empty session parameters' => array(Url::createFromUrl(self::BROWSER_URL_TEST . '?propertyId[0]=cmis:name&propertyValue[0]=name' . '&propertyId[1]=cmis:description&propertyValue[1]=description' . '&changeToken=changeToken&cmisaction=update&succinct=false'), 'repositoryId', 'objectId', $propertySet1, 'changeToken', array()), 'Parameter set with empty changeToken and defined session parameter' => array(Url::createFromUrl(self::BROWSER_URL_TEST . '?propertyId[0]=cmis:name&propertyValue[0]=foo' . '&propertyId[1]=cmis:description&propertyValue[1]=bar' . '&cmisaction=update&succinct=true'), 'repositoryId', 'objectId', $propertySet2, null, array(array(SessionParameter::BROWSER_SUCCINCT, null, true))), 'Parameter set with defined changeToken and defined OMIT_CHANGE_TOKENS session parameter' => array(Url::createFromUrl(self::BROWSER_URL_TEST . '?propertyId[0]=cmis:name&propertyValue[0]=foo' . '&propertyId[1]=cmis:description&propertyValue[1]=bar' . '&cmisaction=update&succinct=false'), 'repositoryId', 'objectId', $propertySet2, 'changeToken', array(array(SessionParameter::OMIT_CHANGE_TOKENS, false, true)))); }
/** * @param PropertyDataInterface[] $propertiesData * @return Properties */ public function createPropertiesData(array $propertiesData) { $properties = new Properties(); $properties->addProperties($propertiesData); return $properties; }
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')); }