2016-02-03 17:43:45 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2016-02-03 17:43:45 +03:00
|
|
|
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
|
|
|
*
|
|
|
|
* @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/>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-05-25 17:04:15 +03:00
|
|
|
namespace OCA\DAV\Tests\unit\CardDAV;
|
2016-02-03 17:43:45 +03:00
|
|
|
|
|
|
|
use OCA\DAV\CalDAV\BirthdayService;
|
|
|
|
use OCA\DAV\CalDAV\CalDavBackend;
|
|
|
|
use OCA\DAV\CardDAV\CardDavBackend;
|
2016-03-23 16:12:50 +03:00
|
|
|
use OCA\DAV\DAV\GroupPrincipalBackend;
|
2017-11-11 03:27:48 +03:00
|
|
|
use OCP\IConfig;
|
2018-11-27 20:41:40 +03:00
|
|
|
use OCP\IDBConnection;
|
2019-08-21 11:35:17 +03:00
|
|
|
use OCP\IL10N;
|
2016-02-03 17:43:45 +03:00
|
|
|
use Sabre\VObject\Component\VCalendar;
|
2016-02-18 16:49:45 +03:00
|
|
|
use Sabre\VObject\Reader;
|
2016-02-03 17:43:45 +03:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
class BirthdayServiceTest extends TestCase {
|
|
|
|
|
|
|
|
/** @var BirthdayService */
|
|
|
|
private $service;
|
|
|
|
/** @var CalDavBackend | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $calDav;
|
|
|
|
/** @var CardDavBackend | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $cardDav;
|
2016-03-23 16:12:50 +03:00
|
|
|
/** @var GroupPrincipalBackend | \PHPUnit_Framework_MockObject_MockObject */
|
2016-09-30 11:29:27 +03:00
|
|
|
private $groupPrincipalBackend;
|
2017-11-11 03:27:48 +03:00
|
|
|
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $config;
|
2018-11-27 20:41:40 +03:00
|
|
|
/** @var IDBConnection | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $dbConnection;
|
2019-08-21 11:35:17 +03:00
|
|
|
/** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $l10n;
|
2016-02-03 17:43:45 +03:00
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
2017-11-11 03:27:48 +03:00
|
|
|
$this->calDav = $this->createMock(CalDavBackend::class);
|
|
|
|
$this->cardDav = $this->createMock(CardDavBackend::class);
|
|
|
|
$this->groupPrincipalBackend = $this->createMock(GroupPrincipalBackend::class);
|
|
|
|
$this->config = $this->createMock(IConfig::class);
|
2018-11-27 20:41:40 +03:00
|
|
|
$this->dbConnection = $this->createMock(IDBConnection::class);
|
2019-08-21 11:35:17 +03:00
|
|
|
$this->l10n = $this->createMock(IL10N::class);
|
2016-02-03 17:43:45 +03:00
|
|
|
|
2019-08-21 11:35:17 +03:00
|
|
|
$this->l10n->expects($this->any())
|
|
|
|
->method('t')
|
|
|
|
->willReturnCallback(function($string, $args) {
|
|
|
|
return vsprintf($string, $args);
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->service = new BirthdayService($this->calDav,$this->cardDav,
|
|
|
|
$this->groupPrincipalBackend, $this->config,
|
|
|
|
$this->dbConnection, $this->l10n);
|
2016-02-03 17:43:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider providesVCards
|
2018-10-14 22:20:04 +03:00
|
|
|
* @param string $expectedSummary
|
|
|
|
* @param string $expectedDTStart
|
|
|
|
* @param string $expectedFieldType
|
|
|
|
* @param string $expectedUnknownYear
|
|
|
|
* @param string $expectedOriginalYear
|
2016-02-03 17:43:45 +03:00
|
|
|
* @param string | null $data
|
|
|
|
*/
|
2019-08-21 11:35:17 +03:00
|
|
|
public function testBuildBirthdayFromContact($expectedSummary, $expectedDTStart, $expectedFieldType, $expectedUnknownYear, $expectedOriginalYear, $data, $fieldType, $prefix, $supports4Bytes) {
|
2018-11-27 20:41:40 +03:00
|
|
|
$this->dbConnection->method('supports4ByteText')->willReturn($supports4Bytes);
|
2019-08-21 11:35:17 +03:00
|
|
|
$cal = $this->service->buildDateFromContact($data, $fieldType, $prefix);
|
2018-11-27 20:41:40 +03:00
|
|
|
|
2016-12-08 01:10:11 +03:00
|
|
|
if ($expectedSummary === null) {
|
2016-02-03 17:43:45 +03:00
|
|
|
$this->assertNull($cal);
|
|
|
|
} else {
|
|
|
|
$this->assertInstanceOf('Sabre\VObject\Component\VCalendar', $cal);
|
|
|
|
$this->assertTrue(isset($cal->VEVENT));
|
|
|
|
$this->assertEquals('FREQ=YEARLY', $cal->VEVENT->RRULE->getValue());
|
2016-12-08 01:10:11 +03:00
|
|
|
$this->assertEquals($expectedSummary, $cal->VEVENT->SUMMARY->getValue());
|
2018-10-14 22:20:04 +03:00
|
|
|
$this->assertEquals($expectedDTStart, $cal->VEVENT->DTSTART->getValue());
|
|
|
|
$this->assertEquals($expectedFieldType, $cal->VEVENT->{'X-NEXTCLOUD-BC-FIELD-TYPE'}->getValue());
|
|
|
|
$this->assertEquals($expectedUnknownYear, $cal->VEVENT->{'X-NEXTCLOUD-BC-UNKNOWN-YEAR'}->getValue());
|
|
|
|
|
|
|
|
if ($expectedOriginalYear) {
|
|
|
|
$this->assertEquals($expectedOriginalYear, $cal->VEVENT->{'X-NEXTCLOUD-BC-YEAR'}->getValue());
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:43:45 +03:00
|
|
|
$this->assertEquals('TRANSPARENT', $cal->VEVENT->TRANSP->getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-11 03:27:48 +03:00
|
|
|
public function testOnCardDeleteGloballyDisabled() {
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('no'));
|
|
|
|
|
|
|
|
$this->cardDav->expects($this->never())->method('getAddressBookById');
|
|
|
|
|
|
|
|
$this->service->onCardDeleted(666, 'gump.vcf');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOnCardDeleteUserDisabled() {
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('yes'));
|
|
|
|
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getUserValue')
|
|
|
|
->with('user01', 'dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('no'));
|
|
|
|
|
|
|
|
$this->cardDav->expects($this->once())->method('getAddressBookById')
|
|
|
|
->with(666)
|
|
|
|
->willReturn([
|
|
|
|
'principaluri' => 'principals/users/user01',
|
|
|
|
'uri' => 'default'
|
|
|
|
]);
|
|
|
|
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
|
|
|
|
$this->calDav->expects($this->never())->method('getCalendarByUri');
|
|
|
|
$this->calDav->expects($this->never())->method('deleteCalendarObject');
|
|
|
|
|
|
|
|
$this->service->onCardDeleted(666, 'gump.vcf');
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:43:45 +03:00
|
|
|
public function testOnCardDeleted() {
|
2017-11-11 03:27:48 +03:00
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('yes'));
|
|
|
|
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getUserValue')
|
|
|
|
->with('user01', 'dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('yes'));
|
|
|
|
|
2016-02-03 17:43:45 +03:00
|
|
|
$this->cardDav->expects($this->once())->method('getAddressBookById')
|
|
|
|
->with(666)
|
|
|
|
->willReturn([
|
|
|
|
'principaluri' => 'principals/users/user01',
|
|
|
|
'uri' => 'default'
|
|
|
|
]);
|
|
|
|
$this->calDav->expects($this->once())->method('getCalendarByUri')
|
|
|
|
->with('principals/users/user01', 'contact_birthdays')
|
|
|
|
->willReturn([
|
|
|
|
'id' => 1234
|
|
|
|
]);
|
2016-09-30 11:29:27 +03:00
|
|
|
$this->calDav->expects($this->at(1))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf.ics');
|
|
|
|
$this->calDav->expects($this->at(2))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf-death.ics');
|
|
|
|
$this->calDav->expects($this->at(3))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf-anniversary.ics');
|
2016-03-23 16:12:50 +03:00
|
|
|
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
|
2016-02-03 17:43:45 +03:00
|
|
|
|
|
|
|
$this->service->onCardDeleted(666, 'gump.vcf');
|
|
|
|
}
|
|
|
|
|
2017-11-11 03:27:48 +03:00
|
|
|
public function testOnCardChangedGloballyDisabled() {
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('no'));
|
|
|
|
|
|
|
|
$this->cardDav->expects($this->never())->method('getAddressBookById');
|
|
|
|
|
|
|
|
$service = $this->getMockBuilder(BirthdayService::class)
|
|
|
|
->setMethods(['buildDateFromContact', 'birthdayEvenChanged'])
|
2019-08-21 11:35:17 +03:00
|
|
|
->setConstructorArgs([$this->calDav, $this->cardDav, $this->groupPrincipalBackend, $this->config, $this->dbConnection, $this->l10n])
|
2017-11-11 03:27:48 +03:00
|
|
|
->getMock();
|
|
|
|
|
|
|
|
$service->onCardChanged(666, 'gump.vcf', '');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOnCardChangedUserDisabled() {
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('yes'));
|
|
|
|
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getUserValue')
|
|
|
|
->with('user01', 'dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('no'));
|
|
|
|
|
|
|
|
$this->cardDav->expects($this->once())->method('getAddressBookById')
|
|
|
|
->with(666)
|
|
|
|
->willReturn([
|
|
|
|
'principaluri' => 'principals/users/user01',
|
|
|
|
'uri' => 'default'
|
|
|
|
]);
|
|
|
|
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
|
|
|
|
$this->calDav->expects($this->never())->method('getCalendarByUri');
|
|
|
|
|
|
|
|
/** @var BirthdayService | \PHPUnit_Framework_MockObject_MockObject $service */
|
|
|
|
$service = $this->getMockBuilder(BirthdayService::class)
|
|
|
|
->setMethods(['buildDateFromContact', 'birthdayEvenChanged'])
|
2019-08-21 11:35:17 +03:00
|
|
|
->setConstructorArgs([$this->calDav, $this->cardDav, $this->groupPrincipalBackend, $this->config, $this->dbConnection, $this->l10n])
|
2017-11-11 03:27:48 +03:00
|
|
|
->getMock();
|
|
|
|
|
|
|
|
$service->onCardChanged(666, 'gump.vcf', '');
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:43:45 +03:00
|
|
|
/**
|
|
|
|
* @dataProvider providesCardChanges
|
|
|
|
*/
|
|
|
|
public function testOnCardChanged($expectedOp) {
|
2017-11-11 03:27:48 +03:00
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('yes'));
|
|
|
|
|
|
|
|
$this->config->expects($this->once())
|
|
|
|
->method('getUserValue')
|
|
|
|
->with('user01', 'dav', 'generateBirthdayCalendar', 'yes')
|
|
|
|
->will($this->returnValue('yes'));
|
|
|
|
|
2016-02-03 17:43:45 +03:00
|
|
|
$this->cardDav->expects($this->once())->method('getAddressBookById')
|
|
|
|
->with(666)
|
|
|
|
->willReturn([
|
|
|
|
'principaluri' => 'principals/users/user01',
|
|
|
|
'uri' => 'default'
|
|
|
|
]);
|
|
|
|
$this->calDav->expects($this->once())->method('getCalendarByUri')
|
|
|
|
->with('principals/users/user01', 'contact_birthdays')
|
|
|
|
->willReturn([
|
|
|
|
'id' => 1234
|
|
|
|
]);
|
2016-03-23 16:12:50 +03:00
|
|
|
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
|
2016-02-03 17:43:45 +03:00
|
|
|
|
|
|
|
/** @var BirthdayService | \PHPUnit_Framework_MockObject_MockObject $service */
|
2016-09-30 11:29:27 +03:00
|
|
|
$service = $this->getMockBuilder(BirthdayService::class)
|
|
|
|
->setMethods(['buildDateFromContact', 'birthdayEvenChanged'])
|
2019-08-21 11:35:17 +03:00
|
|
|
->setConstructorArgs([$this->calDav, $this->cardDav, $this->groupPrincipalBackend, $this->config, $this->dbConnection, $this->l10n])
|
2016-07-15 10:52:46 +03:00
|
|
|
->getMock();
|
2016-02-03 17:43:45 +03:00
|
|
|
|
|
|
|
if ($expectedOp === 'delete') {
|
2016-09-30 11:29:27 +03:00
|
|
|
$this->calDav->expects($this->exactly(3))->method('getCalendarObject')->willReturn('');
|
|
|
|
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(null);
|
|
|
|
$this->calDav->expects($this->exactly(3))->method('deleteCalendarObject')->withConsecutive(
|
|
|
|
[1234, 'default-gump.vcf.ics'],
|
|
|
|
[1234, 'default-gump.vcf-death.ics'],
|
|
|
|
[1234, 'default-gump.vcf-anniversary.ics']
|
|
|
|
);
|
2016-02-03 17:43:45 +03:00
|
|
|
}
|
|
|
|
if ($expectedOp === 'create') {
|
2016-09-30 11:29:27 +03:00
|
|
|
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar());
|
|
|
|
$this->calDav->expects($this->exactly(3))->method('createCalendarObject')->withConsecutive(
|
2018-11-01 11:58:28 +03:00
|
|
|
[1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"],
|
|
|
|
[1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"],
|
|
|
|
[1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"]
|
2016-09-30 11:29:27 +03:00
|
|
|
);
|
2016-02-03 17:43:45 +03:00
|
|
|
}
|
|
|
|
if ($expectedOp === 'update') {
|
2016-09-30 11:29:27 +03:00
|
|
|
$service->expects($this->exactly(3))->method('buildDateFromContact')->willReturn(new VCalendar());
|
|
|
|
$service->expects($this->exactly(3))->method('birthdayEvenChanged')->willReturn(true);
|
|
|
|
$this->calDav->expects($this->exactly(3))->method('getCalendarObject')->willReturn(['calendardata' => '']);
|
|
|
|
$this->calDav->expects($this->exactly(3))->method('updateCalendarObject')->withConsecutive(
|
2018-11-01 11:58:28 +03:00
|
|
|
[1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"],
|
|
|
|
[1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"],
|
|
|
|
[1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.6//EN\r\nCALSCALE:GREGORIAN\r\nEND:VCALENDAR\r\n"]
|
2016-09-30 11:29:27 +03:00
|
|
|
);
|
2016-02-03 17:43:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$service->onCardChanged(666, 'gump.vcf', '');
|
|
|
|
}
|
|
|
|
|
2016-02-18 16:49:45 +03:00
|
|
|
/**
|
|
|
|
* @dataProvider providesBirthday
|
|
|
|
* @param $expected
|
|
|
|
* @param $old
|
|
|
|
* @param $new
|
|
|
|
*/
|
|
|
|
public function testBirthdayEvenChanged($expected, $old, $new) {
|
|
|
|
$new = Reader::read($new);
|
|
|
|
$this->assertEquals($expected, $this->service->birthdayEvenChanged($old, $new));
|
|
|
|
}
|
|
|
|
|
2016-03-23 16:12:50 +03:00
|
|
|
public function testGetAllAffectedPrincipals() {
|
|
|
|
$this->cardDav->expects($this->once())->method('getShares')->willReturn([
|
|
|
|
[
|
|
|
|
'{http://owncloud.org/ns}group-share' => false,
|
|
|
|
'{http://owncloud.org/ns}principal' => 'principals/users/user01'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'{http://owncloud.org/ns}group-share' => false,
|
|
|
|
'{http://owncloud.org/ns}principal' => 'principals/users/user01'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'{http://owncloud.org/ns}group-share' => false,
|
|
|
|
'{http://owncloud.org/ns}principal' => 'principals/users/user02'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'{http://owncloud.org/ns}group-share' => true,
|
|
|
|
'{http://owncloud.org/ns}principal' => 'principals/groups/users'
|
|
|
|
],
|
|
|
|
]);
|
2016-09-30 11:29:27 +03:00
|
|
|
$this->groupPrincipalBackend->expects($this->once())->method('getGroupMemberSet')
|
2016-03-23 16:12:50 +03:00
|
|
|
->willReturn([
|
|
|
|
[
|
|
|
|
'uri' => 'principals/users/user01',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'uri' => 'principals/users/user02',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'uri' => 'principals/users/user03',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
$users = $this->invokePrivate($this->service, 'getAllAffectedPrincipals', [6666]);
|
|
|
|
$this->assertEquals([
|
|
|
|
'principals/users/user01',
|
|
|
|
'principals/users/user02',
|
|
|
|
'principals/users/user03'
|
|
|
|
], $users);
|
|
|
|
}
|
|
|
|
|
2016-07-28 15:19:39 +03:00
|
|
|
public function testBirthdayCalendarHasComponentEvent() {
|
|
|
|
$this->calDav->expects($this->once())
|
|
|
|
->method('createCalendar')
|
|
|
|
->with('principal001', 'contact_birthdays', [
|
|
|
|
'{DAV:}displayname' => 'Contact birthdays',
|
|
|
|
'{http://apple.com/ns/ical/}calendar-color' => '#FFFFCA',
|
|
|
|
'components' => 'VEVENT',
|
|
|
|
]);
|
|
|
|
$this->service->ensureCalendarExists('principal001');
|
|
|
|
}
|
|
|
|
|
2019-02-16 18:18:58 +03:00
|
|
|
public function testResetForUser() {
|
|
|
|
$this->calDav->expects($this->at(0))
|
|
|
|
->method('getCalendarByUri')
|
|
|
|
->with('principals/users/user123', 'contact_birthdays')
|
|
|
|
->willReturn(['id' => 42]);
|
|
|
|
|
|
|
|
$this->calDav->expects($this->at(1))
|
|
|
|
->method('getCalendarObjects')
|
|
|
|
->with(42, 0)
|
|
|
|
->willReturn([['uri' => '1.ics'], ['uri' => '2.ics'], ['uri' => '3.ics']]);
|
|
|
|
|
|
|
|
$this->calDav->expects($this->at(2))
|
|
|
|
->method('deleteCalendarObject')
|
|
|
|
->with(42, '1.ics', 0);
|
|
|
|
|
|
|
|
$this->calDav->expects($this->at(3))
|
|
|
|
->method('deleteCalendarObject')
|
|
|
|
->with(42, '2.ics', 0);
|
|
|
|
|
|
|
|
$this->calDav->expects($this->at(4))
|
|
|
|
->method('deleteCalendarObject')
|
|
|
|
->with(42, '3.ics', 0);
|
|
|
|
|
|
|
|
$this->service->resetForUser('user123');
|
|
|
|
}
|
|
|
|
|
2016-02-18 16:49:45 +03:00
|
|
|
public function providesBirthday() {
|
|
|
|
return [
|
|
|
|
[true,
|
|
|
|
'',
|
2016-10-13 13:15:10 +03:00
|
|
|
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
|
2016-02-18 16:49:45 +03:00
|
|
|
[false,
|
2016-10-13 13:15:10 +03:00
|
|
|
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
|
|
|
|
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
|
2016-02-18 16:49:45 +03:00
|
|
|
[true,
|
2016-10-13 13:15:10 +03:00
|
|
|
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:4567's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
|
|
|
|
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"],
|
2016-02-18 16:49:45 +03:00
|
|
|
[true,
|
2016-10-13 13:15:10 +03:00
|
|
|
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000101\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n",
|
|
|
|
"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nCALSCALE:GREGORIAN\r\nBEGIN:VEVENT\r\nUID:12345\r\nDTSTAMP:20160218T133704Z\r\nDTSTART;VALUE=DATE:19000102\r\nDTEND;VALUE=DATE:19000102\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:12345's Birthday (1900)\r\nTRANSP:TRANSPARENT\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"]
|
2016-02-18 16:49:45 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2016-02-03 17:43:45 +03:00
|
|
|
public function providesCardChanges(){
|
|
|
|
return[
|
|
|
|
['delete'],
|
|
|
|
['create'],
|
|
|
|
['update']
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function providesVCards() {
|
|
|
|
return [
|
2019-08-21 11:35:17 +03:00
|
|
|
// $expectedSummary, $expectedDTStart, $expectedFieldType, $expectedUnknownYear, $expectedOriginalYear, $data, $fieldType, $prefix, $supports4Byte
|
|
|
|
[null, null, null, null, null, 'yasfewf', '', '', true],
|
|
|
|
[null, null, null, null, null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
[null, null, null, null, null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
[null, null, null, null, null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:someday\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
['🎂 12345 (1900)', '19700101', 'BDAY', '0', '1900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:19000101\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
['🎂 12345 (1900)', '19701231', 'BDAY', '0', '1900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:19001231\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
['Death of 12345 (1900)', '19701231', 'DEATHDATE', '0', '1900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nDEATHDATE:19001231\r\nEND:VCARD\r\n", 'DEATHDATE', '-death', true],
|
|
|
|
['Death of 12345 (1900)', '19701231', 'DEATHDATE', '0', '1900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nDEATHDATE:19001231\r\nEND:VCARD\r\n", 'DEATHDATE', '-death', false],
|
|
|
|
['💍 12345 (1900)', '19701231', 'ANNIVERSARY', '0', '1900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nANNIVERSARY:19001231\r\nEND:VCARD\r\n", 'ANNIVERSARY', '-anniversary', true],
|
|
|
|
['12345 (⚭1900)', '19701231', 'ANNIVERSARY', '0', '1900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nANNIVERSARY:19001231\r\nEND:VCARD\r\n", 'ANNIVERSARY', '-anniversary', false],
|
|
|
|
['🎂 12345', '19701231', 'BDAY', '1', null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:--1231\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
['🎂 12345', '19701231', 'BDAY', '1', null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY;X-APPLE-OMIT-YEAR=1604:16041231\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
[null, null, null, null, null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:;VALUE=text:circa 1800\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
[null, null, null, null, null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nN:12345;;;;\r\nBDAY:20031231\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
['🎂 12345 (900)', '19701231', 'BDAY', '0', '900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:09001231\r\nEND:VCARD\r\n", 'BDAY', '', true],
|
|
|
|
['12345 (*1900)', '19700101', 'BDAY', '0', '1900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:19000101\r\nEND:VCARD\r\n", 'BDAY', '', false],
|
|
|
|
['12345 (*1900)', '19701231', 'BDAY', '0', '1900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:19001231\r\nEND:VCARD\r\n", 'BDAY', '', false],
|
|
|
|
['12345 *', '19701231', 'BDAY', '1', null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:--1231\r\nEND:VCARD\r\n", 'BDAY', '', false],
|
|
|
|
['12345 *', '19701231', 'BDAY', '1', null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY;X-APPLE-OMIT-YEAR=1604:16041231\r\nEND:VCARD\r\n", 'BDAY', '', false],
|
|
|
|
[null, null, null, null, null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:;VALUE=text:circa 1800\r\nEND:VCARD\r\n", 'BDAY', '', false],
|
|
|
|
[null, null, null, null, null, "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nN:12345;;;;\r\nBDAY:20031231\r\nEND:VCARD\r\n", 'BDAY', '', false],
|
|
|
|
['12345 (*900)', '19701231', 'BDAY', '0', '900', "BEGIN:VCARD\r\nVERSION:3.0\r\nPRODID:-//Sabre//Sabre VObject 4.1.1//EN\r\nUID:12345\r\nFN:12345\r\nN:12345;;;;\r\nBDAY:09001231\r\nEND:VCARD\r\n", 'BDAY', '', false],
|
2016-02-03 17:43:45 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|