Ejemplo n.º 1
0
 public function testMultiCard()
 {
     $this->backend = $this->getMockBuilder('OCA\\DAV\\CardDAV\\CardDavBackend')->setConstructorArgs([$this->db, $this->principal, null])->setMethods(['updateProperties'])->getMock();
     // create a new address book
     $this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []);
     $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
     $this->assertEquals(1, count($books));
     $bookId = $books[0]['id'];
     // create a card
     $uri0 = $this->getUniqueID('card');
     $this->backend->createCard($bookId, $uri0, '');
     $uri1 = $this->getUniqueID('card');
     $this->backend->createCard($bookId, $uri1, '');
     $uri2 = $this->getUniqueID('card');
     $this->backend->createCard($bookId, $uri2, '');
     // get all the cards
     $cards = $this->backend->getCards($bookId);
     $this->assertEquals(3, count($cards));
     $this->assertEquals('', $cards[0]['carddata']);
     $this->assertEquals('', $cards[1]['carddata']);
     $this->assertEquals('', $cards[2]['carddata']);
     // get the cards
     $cards = $this->backend->getMultipleCards($bookId, [$uri1, $uri2]);
     $this->assertEquals(2, count($cards));
     foreach ($cards as $card) {
         $this->assertArrayHasKey('id', $card);
         $this->assertArrayHasKey('uri', $card);
         $this->assertArrayHasKey('lastmodified', $card);
         $this->assertArrayHasKey('etag', $card);
         $this->assertArrayHasKey('size', $card);
         $this->assertEquals('', $card['carddata']);
     }
     // delete the card
     $this->backend->deleteCard($bookId, $uri0);
     $this->backend->deleteCard($bookId, $uri1);
     $this->backend->deleteCard($bookId, $uri2);
     $cards = $this->backend->getCards($bookId);
     $this->assertEquals(0, count($cards));
 }
Ejemplo n.º 2
0
 public function testMultiCard()
 {
     // create a new address book
     $this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []);
     $books = $this->backend->getAddressBooksForUser(self::UNIT_TEST_USER);
     $this->assertEquals(1, count($books));
     $bookId = $books[0]['id'];
     // create a card
     $uri0 = $this->getUniqueID('card');
     $this->backend->createCard($bookId, $uri0, '');
     $uri1 = $this->getUniqueID('card');
     $this->backend->createCard($bookId, $uri1, '');
     $uri2 = $this->getUniqueID('card');
     $this->backend->createCard($bookId, $uri2, '');
     // get all the cards
     $cards = $this->backend->getCards($bookId);
     $this->assertEquals(3, count($cards));
     $this->assertEquals('', $cards[0]['carddata']);
     $this->assertEquals('', $cards[1]['carddata']);
     $this->assertEquals('', $cards[2]['carddata']);
     // get the cards
     $cards = $this->backend->getMultipleCards($bookId, [$uri1, $uri2]);
     $this->assertEquals(2, count($cards));
     foreach ($cards as $card) {
         $this->assertArrayHasKey('id', $card);
         $this->assertArrayHasKey('uri', $card);
         $this->assertArrayHasKey('lastmodified', $card);
         $this->assertArrayHasKey('etag', $card);
         $this->assertArrayHasKey('size', $card);
         $this->assertEquals('', $card['carddata']);
     }
     // delete the card
     $this->backend->deleteCard($bookId, $uri0);
     $this->backend->deleteCard($bookId, $uri1);
     $this->backend->deleteCard($bookId, $uri2);
     $cards = $this->backend->getCards($bookId);
     $this->assertEquals(0, count($cards));
 }