Prevent from creating empty objects
This commit is contained in:
parent
dac422ef97
commit
e0b593ba52
2 changed files with 6 additions and 2 deletions
|
@ -594,7 +594,7 @@ class kolab_storage_folder extends kolab_storage_folder_api
|
||||||
*/
|
*/
|
||||||
public function save(&$object, $type = null, $uid = null)
|
public function save(&$object, $type = null, $uid = null)
|
||||||
{
|
{
|
||||||
if (!$this->valid) {
|
if (!$this->valid && empty($object)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,11 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase
|
||||||
$this->markTestSkipped('No Kolab support');
|
$this->markTestSkipped('No Kolab support');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$folder = new kolab_storage_folder('Contacts', 'contact');
|
||||||
|
|
||||||
|
$saved = $folder->save(null, 'contact');
|
||||||
|
$this->assertFalse($saved);
|
||||||
|
|
||||||
$contact = array(
|
$contact = array(
|
||||||
'name' => 'FN',
|
'name' => 'FN',
|
||||||
'surname' => 'Last',
|
'surname' => 'Last',
|
||||||
|
@ -187,7 +192,6 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase
|
||||||
'organization' => 'Company A.G.'
|
'organization' => 'Company A.G.'
|
||||||
);
|
);
|
||||||
|
|
||||||
$folder = new kolab_storage_folder('Contacts', 'contact');
|
|
||||||
$saved = $folder->save($contact, 'contact');
|
$saved = $folder->save($contact, 'contact');
|
||||||
$this->assertTrue((bool)$saved);
|
$this->assertTrue((bool)$saved);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue