public function testMigration()
 {
     /** @var AddressBookAdapter | \PHPUnit_Framework_MockObject_MockObject $adapter */
     $adapter = $this->mockAdapter();
     /** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $cardDav */
     $cardDav = $this->getMockBuilder('\\OCA\\Dav\\CardDAV\\CardDAVBackend')->disableOriginalConstructor()->getMock();
     $cardDav->method('createAddressBook')->willReturn(666);
     $cardDav->expects($this->once())->method('createAddressBook')->with('principals/users/test01', 'test_contacts');
     $cardDav->expects($this->once())->method('createCard')->with(666, '63f0dd6c-39d5-44be-9d34-34e7a7441fc2.vcf', 'BEGIN:VCARD');
     $m = new \OCA\Dav\Migration\MigrateAddressbooks($adapter, $cardDav);
     $m->migrateForUser('test01');
 }
Beispiel #2
0
 public function testMigration()
 {
     /** @var AddressBookAdapter | \PHPUnit_Framework_MockObject_MockObject $adapter */
     $adapter = $this->mockAdapter([['share_type' => '1', 'share_with' => 'users', 'permissions' => '31'], ['share_type' => '2', 'share_with' => 'adam', 'permissions' => '1']]);
     /** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject $cardDav */
     $cardDav = $this->getMockBuilder('\\OCA\\Dav\\CardDAV\\CardDAVBackend')->disableOriginalConstructor()->getMock();
     $cardDav->expects($this->any())->method('createAddressBook')->willReturn(666);
     $cardDav->expects($this->any())->method('getAddressBookById')->willReturn([]);
     $cardDav->expects($this->once())->method('createAddressBook')->with('principals/users/test01', 'test_contacts');
     $cardDav->expects($this->once())->method('createCard')->with(666, '63f0dd6c-39d5-44be-9d34-34e7a7441fc2.vcf', 'BEGIN:VCARD');
     $cardDav->expects($this->once())->method('updateShares')->with($this->anything(), [['href' => 'principal:principals/groups/users', 'readOnly' => false], ['href' => 'principal:principals/users/adam', 'readOnly' => true]]);
     /** @var ILogger $logger */
     $logger = $this->getMockBuilder('\\OCP\\ILogger')->disableOriginalConstructor()->getMock();
     $m = new \OCA\Dav\Migration\MigrateAddressbooks($adapter, $cardDav, $logger, null);
     $m->migrateForUser('test01');
 }