summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorblizzz <blizzz@arthur-schiwon.de>2017-10-31 15:05:26 +0100
committerGitHub <noreply@github.com>2017-10-31 15:05:26 +0100
commitb3ff9a2248f18fac4b2a9ffa5be99c464effb4b6 (patch)
treee6a1524c973307d17b0b89e20ed161b72c6687dd /apps
parent6ddda3d7d4173bf0203bd2556f7a2d13aea22195 (diff)
parent143ff6a622a3349a01dd0347d069f824b0f24c4c (diff)
downloadnextcloud-server-b3ff9a2248f18fac4b2a9ffa5be99c464effb4b6.tar.gz
nextcloud-server-b3ff9a2248f18fac4b2a9ffa5be99c464effb4b6.zip
Merge pull request #6849 from nextcloud/fix-missing-translation-of-personal-calendar-in-activity
Fix missing translation of "Personal" calendar in activities
Diffstat (limited to 'apps')
-rw-r--r--apps/comments/lib/Activity/Provider.php6
-rw-r--r--apps/dav/lib/CalDAV/Activity/Backend.php66
-rw-r--r--apps/dav/lib/CalDAV/Activity/Provider/Base.php28
-rw-r--r--apps/dav/lib/CalDAV/Activity/Provider/Calendar.php60
-rw-r--r--apps/dav/lib/CalDAV/Activity/Provider/Event.php30
-rw-r--r--apps/dav/lib/CalDAV/Activity/Provider/Todo.php34
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/BackendTest.php8
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php36
8 files changed, 235 insertions, 33 deletions
diff --git a/apps/comments/lib/Activity/Provider.php b/apps/comments/lib/Activity/Provider.php
index a691d7dd644..41ab8ea8b8e 100644
--- a/apps/comments/lib/Activity/Provider.php
+++ b/apps/comments/lib/Activity/Provider.php
@@ -174,6 +174,12 @@ class Provider implements IProvider {
}
// Fix subjects from 12.0.3 and older
+ //
+ // Do NOT Remove unless necessary
+ // Removing this will break parsing of activities that were created on
+ // Nextcloud 12, so we should keep this as long as it's acceptable.
+ // Otherwise if people upgrade over multiple releases in a short period,
+ // they will get the dead entries in their stream.
return [
'actor' => $subjectParameters[0],
'fileId' => (int) $event->getObjectId(),
diff --git a/apps/dav/lib/CalDAV/Activity/Backend.php b/apps/dav/lib/CalDAV/Activity/Backend.php
index f8cc82407fd..c1a68c1682c 100644
--- a/apps/dav/lib/CalDAV/Activity/Backend.php
+++ b/apps/dav/lib/CalDAV/Activity/Backend.php
@@ -135,8 +135,12 @@ class Backend {
->setSubject(
$user === $currentUser ? $action . '_self' : $action,
[
- $currentUser,
- $calendarData['{DAV:}displayname'],
+ 'actor' => $currentUser,
+ 'calendar' => [
+ 'id' => (int) $calendarData['id'],
+ 'uri' => $calendarData['uri'],
+ 'name' => $calendarData['{DAV:}displayname'],
+ ],
]
);
$this->activityManager->publish($event);
@@ -187,8 +191,13 @@ class Backend {
if ($owner !== $principal[2]) {
$parameters = [
- $principal[2],
- $calendarData['{DAV:}displayname'],
+ 'actor' => $event->getAuthor(),
+ 'calendar' => [
+ 'id' => (int) $calendarData['id'],
+ 'uri' => $calendarData['uri'],
+ 'name' => $calendarData['{DAV:}displayname'],
+ ],
+ 'user' => $principal[2],
];
if ($owner === $event->getAuthor()) {
@@ -201,7 +210,6 @@ class Backend {
$this->activityManager->publish($event);
$subject = Calendar::SUBJECT_UNSHARE_USER . '_by';
- $parameters[] = $event->getAuthor();
}
$event->setAffectedUser($owner)
@@ -212,8 +220,13 @@ class Backend {
$this->triggerActivityGroup($principal[2], $event, $calendarData, Calendar::SUBJECT_UNSHARE_USER);
$parameters = [
- $principal[2],
- $calendarData['{DAV:}displayname'],
+ 'actor' => $event->getAuthor(),
+ 'calendar' => [
+ 'id' => (int) $calendarData['id'],
+ 'uri' => $calendarData['uri'],
+ 'name' => $calendarData['{DAV:}displayname'],
+ ],
+ 'group' => $principal[2],
];
if ($owner === $event->getAuthor()) {
@@ -224,7 +237,6 @@ class Backend {
$this->activityManager->publish($event);
$subject = Calendar::SUBJECT_UNSHARE_GROUP . '_by';
- $parameters[] = $event->getAuthor();
}
$event->setAffectedUser($owner)
@@ -250,8 +262,13 @@ class Backend {
if ($owner !== $principal[2]) {
$parameters = [
- $principal[2],
- $calendarData['{DAV:}displayname'],
+ 'actor' => $event->getAuthor(),
+ 'calendar' => [
+ 'id' => (int) $calendarData['id'],
+ 'uri' => $calendarData['uri'],
+ 'name' => $calendarData['{DAV:}displayname'],
+ ],
+ 'user' => $principal[2],
];
if ($owner === $event->getAuthor()) {
@@ -262,7 +279,6 @@ class Backend {
$this->activityManager->publish($event);
$subject = Calendar::SUBJECT_SHARE_USER . '_by';
- $parameters[] = $event->getAuthor();
}
$event->setAffectedUser($owner)
@@ -273,8 +289,13 @@ class Backend {
$this->triggerActivityGroup($principal[2], $event, $calendarData, Calendar::SUBJECT_SHARE_USER);
$parameters = [
- $principal[2],
- $calendarData['{DAV:}displayname'],
+ 'actor' => $event->getAuthor(),
+ 'calendar' => [
+ 'id' => (int) $calendarData['id'],
+ 'uri' => $calendarData['uri'],
+ 'name' => $calendarData['{DAV:}displayname'],
+ ],
+ 'group' => $principal[2],
];
if ($owner === $event->getAuthor()) {
@@ -285,7 +306,6 @@ class Backend {
$this->activityManager->publish($event);
$subject = Calendar::SUBJECT_SHARE_GROUP . '_by';
- $parameters[] = $event->getAuthor();
}
$event->setAffectedUser($owner)
@@ -347,8 +367,12 @@ class Backend {
->setSubject(
$user === $event->getAuthor() && $subjectSelf ? $subjectSelf : $subject,
[
- $event->getAuthor(),
- $properties['{DAV:}displayname'],
+ 'actor' => $event->getAuthor(),
+ 'calendar' => [
+ 'id' => (int) $properties['id'],
+ 'uri' => $properties['uri'],
+ 'name' => $properties['{DAV:}displayname'],
+ ],
]
);
@@ -401,9 +425,13 @@ class Backend {
->setSubject(
$user === $currentUser ? $action . '_self' : $action,
[
- $currentUser,
- $calendarData['{DAV:}displayname'],
- [
+ 'actor' => $event->getAuthor(),
+ 'calendar' => [
+ 'id' => (int) $calendarData['id'],
+ 'uri' => $calendarData['uri'],
+ 'name' => $calendarData['{DAV:}displayname'],
+ ],
+ 'object' => [
'id' => $object['id'],
'name' => $object['name'],
],
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Base.php b/apps/dav/lib/CalDAV/Activity/Provider/Base.php
index 72fdd681b8a..983d05310ac 100644
--- a/apps/dav/lib/CalDAV/Activity/Provider/Base.php
+++ b/apps/dav/lib/CalDAV/Activity/Provider/Base.php
@@ -21,8 +21,10 @@
namespace OCA\DAV\CalDAV\Activity\Provider;
+use OCA\DAV\CalDAV\CalDavBackend;
use OCP\Activity\IEvent;
use OCP\Activity\IProvider;
+use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
@@ -64,7 +66,7 @@ abstract class Base implements IProvider {
protected function generateObjectParameter($eventData) {
if (!is_array($eventData) || !isset($eventData['id']) || !isset($eventData['name'])) {
throw new \InvalidArgumentException();
- };
+ }
return [
'type' => 'calendar-event',
@@ -74,11 +76,33 @@ abstract class Base implements IProvider {
}
/**
+ * @param array $data
+ * @param IL10N $l
+ * @return array
+ */
+ protected function generateCalendarParameter($data, IL10N $l) {
+ if ($data['uri'] === CalDavBackend::PERSONAL_CALENDAR_URI &&
+ $data['name'] === CalDavBackend::PERSONAL_CALENDAR_NAME) {
+ return [
+ 'type' => 'calendar',
+ 'id' => $data['id'],
+ 'name' => $l->t('Personal'),
+ ];
+ }
+
+ return [
+ 'type' => 'calendar',
+ 'id' => $data['id'],
+ 'name' => $data['name'],
+ ];
+ }
+
+ /**
* @param int $id
* @param string $name
* @return array
*/
- protected function generateCalendarParameter($id, $name) {
+ protected function generateLegacyCalendarParameter($id, $name) {
return [
'type' => 'calendar',
'id' => $id,
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
index 36d425ecf63..fb4a0ff45a8 100644
--- a/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
+++ b/apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
@@ -156,6 +156,56 @@ class Calendar extends Base {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
+ // Nextcloud 13+
+ if (isset($parameters['calendar'])) {
+ switch ($subject) {
+ case self::SUBJECT_ADD:
+ case self::SUBJECT_ADD . '_self':
+ case self::SUBJECT_DELETE:
+ case self::SUBJECT_DELETE . '_self':
+ case self::SUBJECT_UPDATE:
+ case self::SUBJECT_UPDATE . '_self':
+ case self::SUBJECT_SHARE_USER:
+ case self::SUBJECT_UNSHARE_USER:
+ case self::SUBJECT_UNSHARE_USER . '_self':
+ return [
+ 'actor' => $this->generateUserParameter($parameters['actor']),
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ ];
+ case self::SUBJECT_SHARE_USER . '_you':
+ case self::SUBJECT_UNSHARE_USER . '_you':
+ return [
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ 'user' => $this->generateUserParameter($parameters['user']),
+ ];
+ case self::SUBJECT_SHARE_USER . '_by':
+ case self::SUBJECT_UNSHARE_USER . '_by':
+ return [
+ 'actor' => $this->generateUserParameter($parameters['actor']),
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ 'user' => $this->generateUserParameter($parameters['user']),
+ ];
+ case self::SUBJECT_SHARE_GROUP . '_you':
+ case self::SUBJECT_UNSHARE_GROUP . '_you':
+ return [
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ 'group' => $this->generateGroupParameter($parameters['group']),
+ ];
+ case self::SUBJECT_SHARE_GROUP . '_by':
+ case self::SUBJECT_UNSHARE_GROUP . '_by':
+ return [
+ 'actor' => $this->generateUserParameter($parameters['actor']),
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ 'group' => $this->generateGroupParameter($parameters['group']),
+ ];
+ }
+ }
+
+ // Legacy - Do NOT Remove unless necessary
+ // Removing this will break parsing of activities that were created on
+ // Nextcloud 12, so we should keep this as long as it's acceptable.
+ // Otherwise if people upgrade over multiple releases in a short period,
+ // they will get the dead entries in their stream.
switch ($subject) {
case self::SUBJECT_ADD:
case self::SUBJECT_ADD . '_self':
@@ -168,32 +218,32 @@ class Calendar extends Base {
case self::SUBJECT_UNSHARE_USER . '_self':
return [
'actor' => $this->generateUserParameter($parameters[0]),
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
];
case self::SUBJECT_SHARE_USER . '_you':
case self::SUBJECT_UNSHARE_USER . '_you':
return [
'user' => $this->generateUserParameter($parameters[0]),
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
];
case self::SUBJECT_SHARE_USER . '_by':
case self::SUBJECT_UNSHARE_USER . '_by':
return [
'user' => $this->generateUserParameter($parameters[0]),
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'actor' => $this->generateUserParameter($parameters[2]),
];
case self::SUBJECT_SHARE_GROUP . '_you':
case self::SUBJECT_UNSHARE_GROUP . '_you':
return [
'group' => $this->generateGroupParameter($parameters[0]),
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
];
case self::SUBJECT_SHARE_GROUP . '_by':
case self::SUBJECT_UNSHARE_GROUP . '_by':
return [
'group' => $this->generateGroupParameter($parameters[0]),
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'actor' => $this->generateUserParameter($parameters[2]),
];
}
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Event.php b/apps/dav/lib/CalDAV/Activity/Provider/Event.php
index 2c2e3d01c28..7b515d78b14 100644
--- a/apps/dav/lib/CalDAV/Activity/Provider/Event.php
+++ b/apps/dav/lib/CalDAV/Activity/Provider/Event.php
@@ -118,20 +118,46 @@ class Event extends Base {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
+ // Nextcloud 13+
+ if (isset($parameters['calendar'])) {
+ switch ($subject) {
+ case self::SUBJECT_OBJECT_ADD . '_event':
+ case self::SUBJECT_OBJECT_DELETE . '_event':
+ case self::SUBJECT_OBJECT_UPDATE . '_event':
+ return [
+ 'actor' => $this->generateUserParameter($parameters['actor']),
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ 'event' => $this->generateObjectParameter($parameters['object']),
+ ];
+ case self::SUBJECT_OBJECT_ADD . '_event_self':
+ case self::SUBJECT_OBJECT_DELETE . '_event_self':
+ case self::SUBJECT_OBJECT_UPDATE . '_event_self':
+ return [
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ 'event' => $this->generateObjectParameter($parameters['object']),
+ ];
+ }
+ }
+
+ // Legacy - Do NOT Remove unless necessary
+ // Removing this will break parsing of activities that were created on
+ // Nextcloud 12, so we should keep this as long as it's acceptable.
+ // Otherwise if people upgrade over multiple releases in a short period,
+ // they will get the dead entries in their stream.
switch ($subject) {
case self::SUBJECT_OBJECT_ADD . '_event':
case self::SUBJECT_OBJECT_DELETE . '_event':
case self::SUBJECT_OBJECT_UPDATE . '_event':
return [
'actor' => $this->generateUserParameter($parameters[0]),
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'event' => $this->generateObjectParameter($parameters[2]),
];
case self::SUBJECT_OBJECT_ADD . '_event_self':
case self::SUBJECT_OBJECT_DELETE . '_event_self':
case self::SUBJECT_OBJECT_UPDATE . '_event_self':
return [
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'event' => $this->generateObjectParameter($parameters[2]),
];
}
diff --git a/apps/dav/lib/CalDAV/Activity/Provider/Todo.php b/apps/dav/lib/CalDAV/Activity/Provider/Todo.php
index a665caa0e6a..20d7afef028 100644
--- a/apps/dav/lib/CalDAV/Activity/Provider/Todo.php
+++ b/apps/dav/lib/CalDAV/Activity/Provider/Todo.php
@@ -87,6 +87,36 @@ class Todo extends Event {
$subject = $event->getSubject();
$parameters = $event->getSubjectParameters();
+ // Nextcloud 13+
+ if (isset($parameters['calendar'])) {
+ switch ($subject) {
+ case self::SUBJECT_OBJECT_ADD . '_todo':
+ case self::SUBJECT_OBJECT_DELETE . '_todo':
+ case self::SUBJECT_OBJECT_UPDATE . '_todo':
+ case self::SUBJECT_OBJECT_UPDATE . '_todo_completed':
+ case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action':
+ return [
+ 'actor' => $this->generateUserParameter($parameters['actor']),
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ 'todo' => $this->generateObjectParameter($parameters['object']),
+ ];
+ case self::SUBJECT_OBJECT_ADD . '_todo_self':
+ case self::SUBJECT_OBJECT_DELETE . '_todo_self':
+ case self::SUBJECT_OBJECT_UPDATE . '_todo_self':
+ case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self':
+ case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self':
+ return [
+ 'calendar' => $this->generateCalendarParameter($parameters['calendar'], $this->l),
+ 'todo' => $this->generateObjectParameter($parameters['object']),
+ ];
+ }
+ }
+
+ // Legacy - Do NOT Remove unless necessary
+ // Removing this will break parsing of activities that were created on
+ // Nextcloud 12, so we should keep this as long as it's acceptable.
+ // Otherwise if people upgrade over multiple releases in a short period,
+ // they will get the dead entries in their stream.
switch ($subject) {
case self::SUBJECT_OBJECT_ADD . '_todo':
case self::SUBJECT_OBJECT_DELETE . '_todo':
@@ -95,7 +125,7 @@ class Todo extends Event {
case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action':
return [
'actor' => $this->generateUserParameter($parameters[0]),
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'todo' => $this->generateObjectParameter($parameters[2]),
];
case self::SUBJECT_OBJECT_ADD . '_todo_self':
@@ -104,7 +134,7 @@ class Todo extends Event {
case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self':
case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self':
return [
- 'calendar' => $this->generateCalendarParameter((int)$event->getObjectId(), $parameters[1]),
+ 'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'todo' => $this->generateObjectParameter($parameters[2]),
];
}
diff --git a/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php b/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php
index d8d15e8f1f7..dd48d8172d3 100644
--- a/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php
@@ -108,11 +108,13 @@ class BackendTest extends TestCase {
[Calendar::SUBJECT_ADD, [
'principaluri' => 'principal/user/admin',
'id' => 42,
+ 'uri' => 'this-uri',
'{DAV:}displayname' => 'Name of calendar',
], [], [], '', 'admin', null, ['admin']],
[Calendar::SUBJECT_ADD, [
'principaluri' => 'principal/user/admin',
'id' => 42,
+ 'uri' => 'this-uri',
'{DAV:}displayname' => 'Name of calendar',
], [], [], 'test2', 'test2', null, ['admin']],
@@ -122,17 +124,20 @@ class BackendTest extends TestCase {
[Calendar::SUBJECT_UPDATE, [
'principaluri' => 'principal/user/admin',
'id' => 42,
+ 'uri' => 'this-uri',
'{DAV:}displayname' => 'Name of calendar',
], ['shares'], [], '', 'admin', null, ['admin']],
// Visible change
[Calendar::SUBJECT_UPDATE, [
'principaluri' => 'principal/user/admin',
'id' => 42,
+ 'uri' => 'this-uri',
'{DAV:}displayname' => 'Name of calendar',
], ['shares'], ['{DAV:}displayname' => 'Name'], '', 'admin', ['user1'], ['user1', 'admin']],
[Calendar::SUBJECT_UPDATE, [
'principaluri' => 'principal/user/admin',
'id' => 42,
+ 'uri' => 'this-uri',
'{DAV:}displayname' => 'Name of calendar',
], ['shares'], ['{DAV:}displayname' => 'Name'], 'test2', 'test2', ['user1'], ['user1', 'admin']],
@@ -141,16 +146,19 @@ class BackendTest extends TestCase {
[Calendar::SUBJECT_DELETE, [
'principaluri' => 'principal/user/admin',
'id' => 42,
+ 'uri' => 'this-uri',
'{DAV:}displayname' => 'Name of calendar',
], ['shares'], [], '', 'admin', [], ['admin']],
[Calendar::SUBJECT_DELETE, [
'principaluri' => 'principal/user/admin',
'id' => 42,
+ 'uri' => 'this-uri',
'{DAV:}displayname' => 'Name of calendar',
], ['shares'], [], '', 'admin', ['user1'], ['user1', 'admin']],
[Calendar::SUBJECT_DELETE, [
'principaluri' => 'principal/user/admin',
'id' => 42,
+ 'uri' => 'this-uri',
'{DAV:}displayname' => 'Name of calendar',
], ['shares'], [], 'test2', 'test2', ['user1'], ['user1', 'admin']],
];
diff --git a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php
index 85eb439f100..adffaf27ded 100644
--- a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php
+++ b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php
@@ -24,6 +24,7 @@ namespace OCA\DAV\Tests\unit\CalDAV\Activity\Provider;
use OCA\DAV\CalDAV\Activity\Provider\Base;
use OCP\Activity\IEvent;
use OCP\Activity\IProvider;
+use OCP\IL10N;
use OCP\IUser;
use OCP\IUserManager;
use Test\TestCase;
@@ -113,22 +114,51 @@ class BaseTest extends TestCase {
public function dataGenerateCalendarParameter() {
return [
+ [['id' => 23, 'uri' => 'foo', 'name' => 'bar'], 'bar'],
+ [['id' => 42, 'uri' => 'foo', 'name' => 'Personal'], 'Personal'],
+ [['id' => 42, 'uri' => 'personal', 'name' => 'bar'], 'bar'],
+ [['id' => 42, 'uri' => 'personal', 'name' => 'Personal'], 't(Personal)'],
+ ];
+ }
+
+ /**
+ * @dataProvider dataGenerateCalendarParameter
+ * @param array $data
+ * @param string $name
+ */
+ public function testGenerateCalendarParameter(array $data, $name) {
+ $l = $this->createMock(IL10N::class);
+ $l->expects($this->any())
+ ->method('t')
+ ->willReturnCallback(function($string, $args) {
+ return 't(' . vsprintf($string, $args) . ')';
+ });
+
+ $this->assertEquals([
+ 'type' => 'calendar',
+ 'id' => $data['id'],
+ 'name' => $name,
+ ], $this->invokePrivate($this->provider, 'generateCalendarParameter', [$data, $l]));
+ }
+
+ public function dataGenerateLegacyCalendarParameter() {
+ return [
[23, 'c1'],
[42, 'c2'],
];
}
/**
- * @dataProvider dataGenerateCalendarParameter
+ * @dataProvider dataGenerateLegacyCalendarParameter
* @param int $id
* @param string $name
*/
- public function testGenerateCalendarParameter($id, $name) {
+ public function testGenerateLegacyCalendarParameter($id, $name) {
$this->assertEquals([
'type' => 'calendar',
'id' => $id,
'name' => $name,
- ], $this->invokePrivate($this->provider, 'generateCalendarParameter', [$id, $name]));
+ ], $this->invokePrivate($this->provider, 'generateLegacyCalendarParameter', [$id, $name]));
}
public function dataGenerateGroupParameter() {