aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-04-13 15:53:57 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2016-04-13 15:53:57 +0200
commit439de52534917c8588ac04ac3c24d08a13f57197 (patch)
tree27040c5718b32226c81cee795e52f634de3cd8b3 /apps/dav/tests
parent3c0a1d4241c16c13b3fd93406402320284d153d9 (diff)
downloadnextcloud-server-439de52534917c8588ac04ac3c24d08a13f57197.tar.gz
nextcloud-server-439de52534917c8588ac04ac3c24d08a13f57197.zip
Remove dav migration for 9.1
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/unit/migration/addressbookadaptertest.php129
-rw-r--r--apps/dav/tests/unit/migration/calendar_schema.xml191
-rw-r--r--apps/dav/tests/unit/migration/calendaradaptertest.php131
-rw-r--r--apps/dav/tests/unit/migration/contacts_schema.xml151
-rw-r--r--apps/dav/tests/unit/migration/migrateaddressbooktest.php81
-rw-r--r--apps/dav/tests/unit/migration/migratecalendartest.php85
6 files changed, 0 insertions, 768 deletions
diff --git a/apps/dav/tests/unit/migration/addressbookadaptertest.php b/apps/dav/tests/unit/migration/addressbookadaptertest.php
deleted file mode 100644
index e6e57049a93..00000000000
--- a/apps/dav/tests/unit/migration/addressbookadaptertest.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/**
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OCA\DAV\Tests\Unit\Migration;
-
-use DomainException;
-use OCA\Dav\Migration\AddressBookAdapter;
-use OCP\IDBConnection;
-use Test\TestCase;
-
-/**
- * Class AddressbookAdapterTest
- *
- * @group DB
- *
- * @package OCA\DAV\Tests\Unit\Migration
- */
-class AddressbookAdapterTest extends TestCase {
-
- /** @var IDBConnection */
- private $db;
- /** @var AddressBookAdapter */
- private $adapter;
- /** @var array */
- private $books = [];
- /** @var array */
- private $cards = [];
-
- public function setUp() {
- parent::setUp();
- $this->db = \OC::$server->getDatabaseConnection();
-
- $manager = new \OC\DB\MDB2SchemaManager($this->db);
- $manager->createDbFromStructure(__DIR__ . '/contacts_schema.xml');
-
- $this->adapter = new AddressBookAdapter($this->db);
- }
-
- public function tearDown() {
- $this->db->dropTable('contacts_addressbooks');
- $this->db->dropTable('contacts_cards');
- parent::tearDown();
- }
-
- /**
- * @expectedException DomainException
- */
- public function testOldTablesDoNotExist() {
- $adapter = new AddressBookAdapter(\OC::$server->getDatabaseConnection(), 'crazy_table_that_does_no_exist');
- $adapter->setup();
- }
-
- public function test() {
-
- // insert test data
- $builder = $this->db->getQueryBuilder();
- $builder->insert('contacts_addressbooks')
- ->values([
- 'userid' => $builder->createNamedParameter('test-user-666'),
- 'displayname' => $builder->createNamedParameter('Display Name'),
- 'uri' => $builder->createNamedParameter('contacts'),
- 'description' => $builder->createNamedParameter('An address book for testing'),
- 'ctag' => $builder->createNamedParameter('112233'),
- 'active' => $builder->createNamedParameter('1')
- ])
- ->execute();
- $builder = $this->db->getQueryBuilder();
- $builder->insert('contacts_cards')
- ->values([
- 'addressbookid' => $builder->createNamedParameter(6666),
- 'fullname' => $builder->createNamedParameter('Full Name'),
- 'carddata' => $builder->createNamedParameter('datadatadata'),
- 'uri' => $builder->createNamedParameter('some-card.vcf'),
- 'lastmodified' => $builder->createNamedParameter('112233'),
- ])
- ->execute();
- $builder = $this->db->getQueryBuilder();
- $builder->insert('share')
- ->values([
- 'share_type' => $builder->createNamedParameter(1),
- 'share_with' => $builder->createNamedParameter('user01'),
- 'uid_owner' => $builder->createNamedParameter('user02'),
- 'item_type' => $builder->createNamedParameter('addressbook'),
- 'item_source' => $builder->createNamedParameter(6666),
- 'item_target' => $builder->createNamedParameter('Contacts (user02)'),
- ])
- ->execute();
-
- // test the adapter
- $this->adapter->foreachBook('test-user-666', function($row) {
- $this->books[] = $row;
- });
- $this->assertArrayHasKey('id', $this->books[0]);
- $this->assertEquals('test-user-666', $this->books[0]['userid']);
- $this->assertEquals('Display Name', $this->books[0]['displayname']);
- $this->assertEquals('contacts', $this->books[0]['uri']);
- $this->assertEquals('An address book for testing', $this->books[0]['description']);
- $this->assertEquals('112233', $this->books[0]['ctag']);
-
- $this->adapter->foreachCard(6666, function($row) {
- $this->cards[]= $row;
- });
- $this->assertArrayHasKey('id', $this->cards[0]);
- $this->assertEquals(6666, $this->cards[0]['addressbookid']);
-
- // test getShares
- $shares = $this->adapter->getShares(6666);
- $this->assertEquals(1, count($shares));
-
- }
-
-}
diff --git a/apps/dav/tests/unit/migration/calendar_schema.xml b/apps/dav/tests/unit/migration/calendar_schema.xml
deleted file mode 100644
index 6c88b596a3f..00000000000
--- a/apps/dav/tests/unit/migration/calendar_schema.xml
+++ /dev/null
@@ -1,191 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<database>
-
- <name>*dbname*</name>
- <create>true</create>
- <overwrite>false</overwrite>
-
- <charset>utf8</charset>
-
- <table>
-
- <name>*dbprefix*clndr_objects</name>
-
- <declaration>
-
- <field>
- <name>id</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <autoincrement>1</autoincrement>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>calendarid</name>
- <type>integer</type>
- <default></default>
- <notnull>true</notnull>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>objecttype</name>
- <type>text</type>
- <default></default>
- <notnull>true</notnull>
- <length>40</length>
- </field>
-
- <field>
- <name>startdate</name>
- <type>timestamp</type>
- <default>1970-01-01 00:00:00</default>
- <notnull>false</notnull>
- </field>
-
- <field>
- <name>enddate</name>
- <type>timestamp</type>
- <default>1970-01-01 00:00:00</default>
- <notnull>false</notnull>
- </field>
-
- <field>
- <name>repeating</name>
- <type>integer</type>
- <default></default>
- <notnull>false</notnull>
- <length>4</length>
- </field>
-
- <field>
- <name>summary</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>calendardata</name>
- <type>clob</type>
- <notnull>false</notnull>
- </field>
-
- <field>
- <name>uri</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>lastmodified</name>
- <type>integer</type>
- <default></default>
- <notnull>false</notnull>
- <length>4</length>
- </field>
-
- </declaration>
-
- </table>
-
- <table>
-
- <name>*dbprefix*clndr_calendars</name>
-
- <declaration>
-
- <field>
- <name>id</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <autoincrement>1</autoincrement>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>userid</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>displayname</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>100</length>
- </field>
-
- <field>
- <name>uri</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>active</name>
- <type>integer</type>
- <default>1</default>
- <notnull>true</notnull>
- <length>4</length>
- </field>
-
- <field>
- <name>ctag</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>calendarorder</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>calendarcolor</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>10</length>
- </field>
-
- <field>
- <name>timezone</name>
- <type>clob</type>
- <notnull>false</notnull>
- </field>
-
- <field>
- <name>components</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>100</length>
- </field>
-
- </declaration>
-
- </table>
-
-</database>
diff --git a/apps/dav/tests/unit/migration/calendaradaptertest.php b/apps/dav/tests/unit/migration/calendaradaptertest.php
deleted file mode 100644
index f92774ef6ad..00000000000
--- a/apps/dav/tests/unit/migration/calendaradaptertest.php
+++ /dev/null
@@ -1,131 +0,0 @@
-<?php
-/**
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OCA\DAV\Tests\Unit\Migration;
-
-use DomainException;
-use OCA\Dav\Migration\AddressBookAdapter;
-use OCA\Dav\Migration\CalendarAdapter;
-use OCP\IDBConnection;
-use Test\TestCase;
-
-/**
- * Class CalendarAdapterTest
- *
- * @group DB
- *
- * @package OCA\DAV\Tests\Unit\Migration
- */
-class CalendarAdapterTest extends TestCase {
-
- /** @var IDBConnection */
- private $db;
- /** @var CalendarAdapter */
- private $adapter;
- /** @var array */
- private $cals = [];
- /** @var array */
- private $calObjs = [];
-
- public function setUp() {
- parent::setUp();
- $this->db = \OC::$server->getDatabaseConnection();
-
- $manager = new \OC\DB\MDB2SchemaManager($this->db);
- $manager->createDbFromStructure(__DIR__ . '/calendar_schema.xml');
-
- $this->adapter = new CalendarAdapter($this->db);
- }
-
- public function tearDown() {
- $this->db->dropTable('clndr_calendars');
- $this->db->dropTable('clndr_objects');
- parent::tearDown();
- }
-
- /**
- * @expectedException DomainException
- */
- public function testOldTablesDoNotExist() {
- $adapter = new AddressBookAdapter(\OC::$server->getDatabaseConnection(), 'crazy_table_that_does_no_exist');
- $adapter->setup();
- }
-
- public function test() {
-
- // insert test data
- $builder = $this->db->getQueryBuilder();
- $builder->insert('clndr_calendars')
- ->values([
- 'userid' => $builder->createNamedParameter('test-user-666'),
- 'displayname' => $builder->createNamedParameter('Display Name'),
- 'uri' => $builder->createNamedParameter('events'),
- 'ctag' => $builder->createNamedParameter('112233'),
- 'active' => $builder->createNamedParameter('1')
- ])
- ->execute();
- $builder = $this->db->getQueryBuilder();
- $builder->insert('clndr_objects')
- ->values([
- 'calendarid' => $builder->createNamedParameter(6666),
- 'objecttype' => $builder->createNamedParameter('VEVENT'),
- 'startdate' => $builder->createNamedParameter(new \DateTime(), 'datetime'),
- 'enddate' => $builder->createNamedParameter(new \DateTime(), 'datetime'),
- 'repeating' => $builder->createNamedParameter(0),
- 'summary' => $builder->createNamedParameter('Something crazy will happen'),
- 'uri' => $builder->createNamedParameter('event.ics'),
- 'lastmodified' => $builder->createNamedParameter('112233'),
- ])
- ->execute();
- $builder = $this->db->getQueryBuilder();
- $builder->insert('share')
- ->values([
- 'share_type' => $builder->createNamedParameter(1),
- 'share_with' => $builder->createNamedParameter('user01'),
- 'uid_owner' => $builder->createNamedParameter('user02'),
- 'item_type' => $builder->createNamedParameter('calendar'),
- 'item_source' => $builder->createNamedParameter(6666),
- 'item_target' => $builder->createNamedParameter('Contacts (user02)'),
- ])
- ->execute();
-
- // test the adapter
- $this->adapter->foreachCalendar('test-user-666', function($row) {
- $this->cals[] = $row;
- });
- $this->assertArrayHasKey('id', $this->cals[0]);
- $this->assertEquals('test-user-666', $this->cals[0]['userid']);
- $this->assertEquals('Display Name', $this->cals[0]['displayname']);
- $this->assertEquals('events', $this->cals[0]['uri']);
- $this->assertEquals('112233', $this->cals[0]['ctag']);
-
- $this->adapter->foreachCalendarObject(6666, function($row) {
- $this->calObjs[]= $row;
- });
- $this->assertArrayHasKey('id', $this->calObjs[0]);
- $this->assertEquals(6666, $this->calObjs[0]['calendarid']);
-
- // test getShares
- $shares = $this->adapter->getShares(6666);
- $this->assertEquals(1, count($shares));
-
- }
-
-}
diff --git a/apps/dav/tests/unit/migration/contacts_schema.xml b/apps/dav/tests/unit/migration/contacts_schema.xml
deleted file mode 100644
index 51836a1e0c6..00000000000
--- a/apps/dav/tests/unit/migration/contacts_schema.xml
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1" ?>
-<database>
-
- <name>*dbname*</name>
- <create>true</create>
- <overwrite>false</overwrite>
- <charset>utf8</charset>
- <table>
-
- <name>*dbprefix*contacts_addressbooks</name>
-
- <declaration>
-
- <field>
- <name>id</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <autoincrement>1</autoincrement>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>userid</name>
- <type>text</type>
- <default></default>
- <notnull>true</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>displayname</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>uri</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>200</length>
- </field>
-
- <field>
- <name>description</name>
- <type>text</type>
- <notnull>false</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>ctag</name>
- <type>integer</type>
- <default>1</default>
- <notnull>true</notnull>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>active</name>
- <type>integer</type>
- <default>1</default>
- <notnull>true</notnull>
- <length>4</length>
- </field>
-
- <index>
- <name>c_addressbook_userid_index</name>
- <field>
- <name>userid</name>
- <sorting>ascending</sorting>
- </field>
- </index>
- </declaration>
-
- </table>
-
- <table>
-
- <name>*dbprefix*contacts_cards</name>
-
- <declaration>
-
- <field>
- <name>id</name>
- <type>integer</type>
- <default>0</default>
- <notnull>true</notnull>
- <autoincrement>1</autoincrement>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>addressbookid</name>
- <type>integer</type>
- <default></default>
- <notnull>true</notnull>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
- <field>
- <name>fullname</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>255</length>
- </field>
-
- <field>
- <name>carddata</name>
- <type>clob</type>
- <notnull>false</notnull>
- </field>
-
- <field>
- <name>uri</name>
- <type>text</type>
- <default></default>
- <notnull>false</notnull>
- <length>200</length>
- </field>
-
- <field>
- <name>lastmodified</name>
- <type>integer</type>
- <default></default>
- <notnull>false</notnull>
- <unsigned>true</unsigned>
- <length>4</length>
- </field>
-
-
- <index>
- <name>c_addressbookid_index</name>
- <field>
- <name>addressbookid</name>
- <sorting>ascending</sorting>
- </field>
- </index>
- </declaration>
-
- </table>
-
-</database>
diff --git a/apps/dav/tests/unit/migration/migrateaddressbooktest.php b/apps/dav/tests/unit/migration/migrateaddressbooktest.php
deleted file mode 100644
index 31cb16265c0..00000000000
--- a/apps/dav/tests/unit/migration/migrateaddressbooktest.php
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-/**
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OCA\DAV\Tests\Unit\Migration;
-
-use OCA\DAV\CardDAV\CardDavBackend;
-use OCA\Dav\Migration\AddressBookAdapter;
-use OCP\ILogger;
-use Test\TestCase;
-
-class MigrateAddressbookTest extends TestCase {
-
- 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');
- }
-
- /**
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- private function mockAdapter($shares = []) {
- $adapter = $this->getMockBuilder('\OCA\Dav\Migration\AddressBookAdapter')->disableOriginalConstructor()->getMock();
- $adapter->expects($this->any())->method('foreachBook')->willReturnCallback(function ($user, \Closure $callBack) {
- $callBack([
- 'id' => 0,
- 'userid' => $user,
- 'displayname' => 'Test Contacts',
- 'uri' => 'test_contacts',
- 'description' => 'Contacts to test with',
- 'ctag' => 1234567890,
- 'active' => 1
- ]);
- });
- $adapter->expects($this->any())->method('foreachCard')->willReturnCallback(function ($addressBookId, \Closure $callBack) {
- $callBack([
- 'userid' => $addressBookId,
- 'uri' => '63f0dd6c-39d5-44be-9d34-34e7a7441fc2.vcf',
- 'carddata' => 'BEGIN:VCARD'
- ]);
- });
- $adapter->expects($this->any())->method('getShares')->willReturn($shares);
- return $adapter;
- }
-
-}
diff --git a/apps/dav/tests/unit/migration/migratecalendartest.php b/apps/dav/tests/unit/migration/migratecalendartest.php
deleted file mode 100644
index e62970aef34..00000000000
--- a/apps/dav/tests/unit/migration/migratecalendartest.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-/**
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OCA\DAV\Tests\Unit\Migration;
-
-use OCA\DAV\CalDAV\CalDavBackend;
-use OCA\Dav\Migration\CalendarAdapter;
-use OCP\ILogger;
-use Test\TestCase;
-
-class MigrateCalendarTest extends TestCase {
-
- public function testMigration() {
- /** @var CalendarAdapter | \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 CalDavBackend | \PHPUnit_Framework_MockObject_MockObject $cardDav */
- $cardDav = $this->getMockBuilder('\OCA\Dav\CalDAV\CalDAVBackend')->disableOriginalConstructor()->getMock();
- $cardDav->expects($this->any())->method('createCalendar')->willReturn(666);
- $cardDav->expects($this->once())->method('createCalendar')->with('principals/users/test01', 'test_contacts');
- $cardDav->expects($this->once())->method('createCalendarObject')->with(666, '63f0dd6c-39d5-44be-9d34-34e7a7441fc2.ics', '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\MigrateCalendars($adapter, $cardDav, $logger, null);
- $m->migrateForUser('test01');
- }
-
- /**
- * @return \PHPUnit_Framework_MockObject_MockObject
- */
- private function mockAdapter($shares = [], $calData = 'BEGIN:VCARD') {
- $adapter = $this->getMockBuilder('\OCA\Dav\Migration\CalendarAdapter')
- ->disableOriginalConstructor()
- ->getMock();
- $adapter->expects($this->any())->method('foreachCalendar')->willReturnCallback(function ($user, \Closure $callBack) {
- $callBack([
- // calendarorder | calendarcolor | timezone | components
- 'id' => 0,
- 'userid' => $user,
- 'displayname' => 'Test Contacts',
- 'uri' => 'test_contacts',
- 'ctag' => 1234567890,
- 'active' => 1,
- 'calendarorder' => '0',
- 'calendarcolor' => '#b3dc6c',
- 'timezone' => null,
- 'components' => 'VEVENT,VTODO,VJOURNAL'
- ]);
- });
- $adapter->expects($this->any())->method('foreachCalendarObject')->willReturnCallback(function ($addressBookId, \Closure $callBack) use ($calData) {
- $callBack([
- 'userid' => $addressBookId,
- 'uri' => '63f0dd6c-39d5-44be-9d34-34e7a7441fc2.ics',
- 'calendardata' => $calData
- ]);
- });
- $adapter->expects($this->any())->method('getShares')->willReturn($shares);
- return $adapter;
- }
-}