throw new \InvalidArgumentException('String expected.');
}
+ $id = trim($id);
if($this->data['id'] === '' || ($this->data['id'] !== '' && $id === '')) {
$this->data['id'] = $id;
return $this;
if(!is_string($parentId)) {
throw new \InvalidArgumentException('String expected.');
}
- $this->data['parentId'] = $parentId;
+ $this->data['parentId'] = trim($parentId);
return $this;
}
if(!is_string($id)) {
throw new \InvalidArgumentException('String expected.');
}
- $this->data['topmostParentId'] = $id;
+ $this->data['topmostParentId'] = trim($id);
return $this;
}
if(!is_string($message)) {
throw new \InvalidArgumentException('String expected.');
}
- $this->data['message'] = $message;
+ $this->data['message'] = trim($message);
return $this;
}
* @since 9.0.0
*/
public function setVerb($verb) {
- if(!is_string($verb)) {
- throw new \InvalidArgumentException('String expected.');
+ if(!is_string($verb) || empty(trim($verb))) {
+ throw new \InvalidArgumentException('Non-empty String expected.');
}
- $this->data['verb'] = $verb;
+ $this->data['verb'] = trim($verb);
return $this;
}
*/
public function setActor($actorType, $actorId) {
if(
- !is_string($actorType) || empty($actorType)
- || !is_string($actorId) || empty($actorId)
+ !is_string($actorType) || empty(trim($actorType))
+ || !is_string($actorId) || empty(trim($actorId))
) {
throw new \InvalidArgumentException('String expected.');
}
- $this->data['actorType'] = $actorType;
- $this->data['actorId'] = $actorId;
+ $this->data['actorType'] = trim($actorType);
+ $this->data['actorId'] = trim($actorId);
return $this;
}
*/
public function setObject($objectType, $objectId) {
if(
- !is_string($objectType) || empty($objectType)
- || !is_string($objectId) || empty($objectId)
+ !is_string($objectType) || empty(trim($objectType))
+ || !is_string($objectId) || empty(trim($objectId))
) {
throw new \InvalidArgumentException('String expected.');
}
- $this->data['objectType'] = $objectType;
- $this->data['objectId'] = $objectId;
+ $this->data['objectType'] = trim($objectType);
+ $this->data['objectId'] = trim($objectId);
return $this;
}
public function simpleSetterProvider() {
return [
- ['Id'],
- ['ParentId'],
- ['Message'],
- ['Verb'],
- ['ChildrenCount'],
+ ['Id', true],
+ ['ParentId', true],
+ ['Message', true],
+ ['Verb', true],
+ ['Verb', ''],
+ ['ChildrenCount', true],
];
}
/**
* @dataProvider simpleSetterProvider
*/
- public function testSimpleSetterInvalidInput($field) {
+ public function testSimpleSetterInvalidInput($field, $input) {
$comment = new \OC\Comments\Comment();
$setter = 'set' . $field;
$this->setExpectedException('InvalidArgumentException');
- // we have no field that is supposed to accept a Bool
- $comment->$setter(true);
+ $comment->$setter($input);
}
public function roleSetterProvider() {
['Actor', true, true],
['Actor', 'user', true],
['Actor', true, 'alice'],
+ ['Actor', ' ', ' '],
['Object', true, true],
['Object', 'file', true],
['Object', true, 'file64'],
+ ['Object', ' ', ' '],
];
}