/**
  * @param AbstractBackend $backend The storage backend
  * @param array $addressBookInfo
  * @throws \Exception
  */
 public function __construct(Backend\AbstractBackend $backend, array $addressBookInfo)
 {
     self::$l10n = \OCP\Util::getL10N('contacts');
     $this->backend = $backend;
     $this->addressBookInfo = $addressBookInfo;
     if (is_null($this->getId())) {
         $id = $this->backend->createAddressBook($addressBookInfo);
         if ($id === false) {
             throw new \Exception('Error creating address book.', Http::STATUS_INTERNAL_SERVER_ERROR);
         }
         $this->addressBookInfo = $this->backend->getAddressBook($id);
     }
     //\OCP\Util::writeLog('contacts', __METHOD__.' backend: ' . print_r($this->backend, true), \OCP\Util::DEBUG);
 }
Example #2
0
 public function testCreateAddressBookFail()
 {
     // displayname must be provided.
     $id = $this->backend->createAddressBook(array('description' => 'foo bar'));
     $this->assertFalse($id);
 }