1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace OCA\DAV\Tests\unit\CalDAV;
- use OC\Calendar\Manager;
- use OCA\DAV\CalDAV\CalDavBackend;
- use OCA\DAV\CalDAV\CalendarImpl;
- use OCA\DAV\CalDAV\CalendarManager;
- use OCP\Calendar\IManager;
- use OCP\IConfig;
- use OCP\IL10N;
- class CalendarManagerTest extends \Test\TestCase {
-
- private $backend;
-
- private $l10n;
-
- private $config;
-
- private $manager;
- protected function setUp(): void {
- parent::setUp();
- $this->backend = $this->createMock(CalDavBackend::class);
- $this->l10n = $this->createMock(IL10N::class);
- $this->config = $this->createMock(IConfig::class);
- $this->manager = new CalendarManager($this->backend,
- $this->l10n, $this->config);
- }
- public function testSetupCalendarProvider() {
- $this->backend->expects($this->once())
- ->method('getCalendarsForUser')
- ->with('principals/users/user123')
- ->willReturn([
- ['id' => 123, 'uri' => 'blablub1'],
- ['id' => 456, 'uri' => 'blablub2'],
- ]);
-
- $calendarManager = $this->createMock(Manager::class);
- $calendarManager->expects($this->at(0))
- ->method('registerCalendar')
- ->willReturnCallback(function () {
- $parameter = func_get_arg(0);
- $this->assertInstanceOf(CalendarImpl::class, $parameter);
- $this->assertEquals(123, $parameter->getKey());
- });
- $calendarManager->expects($this->at(1))
- ->method('registerCalendar')
- ->willReturnCallback(function () {
- $parameter = func_get_arg(0);
- $this->assertInstanceOf(CalendarImpl::class, $parameter);
- $this->assertEquals(456, $parameter->getKey());
- });
- $this->manager->setupCalendarProvider($calendarManager, 'user123');
- }
- }
|