Fix unit tests for CalendarManager

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
Morris Jobke 2017-12-12 09:33:52 +01:00
parent d98dea1eb1
commit 1ceeab9229
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
2 changed files with 14 additions and 3 deletions

View File

@ -24,6 +24,7 @@
namespace OCA\DAV\CalDAV; namespace OCA\DAV\CalDAV;
use OCP\Calendar\IManager; use OCP\Calendar\IManager;
use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
class CalendarManager { class CalendarManager {
@ -34,15 +35,20 @@ class CalendarManager {
/** @var IL10N */ /** @var IL10N */
private $l10n; private $l10n;
/** @var IConfig */
private $config;
/** /**
* CalendarManager constructor. * CalendarManager constructor.
* *
* @param CalDavBackend $backend * @param CalDavBackend $backend
* @param IL10N $l10n * @param IL10N $l10n
* @param IConfig $config
*/ */
public function __construct(CalDavBackend $backend, IL10N $l10n) { public function __construct(CalDavBackend $backend, IL10N $l10n, IConfig $config) {
$this->backend = $backend; $this->backend = $backend;
$this->l10n = $l10n; $this->l10n = $l10n;
$this->config = $config;
} }
/** /**
@ -60,7 +66,7 @@ class CalendarManager {
*/ */
private function register(IManager $cm, array $calendars) { private function register(IManager $cm, array $calendars) {
foreach($calendars as $calendarInfo) { foreach($calendars as $calendarInfo) {
$calendar = new Calendar($this->backend, $calendarInfo, $this->l10n); $calendar = new Calendar($this->backend, $calendarInfo, $this->l10n, $this->config);
$cm->registerCalendar(new CalendarImpl( $cm->registerCalendar(new CalendarImpl(
$calendar, $calendar,
$calendarInfo, $calendarInfo,

View File

@ -28,6 +28,7 @@ use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\CalDAV\CalendarImpl; use OCA\DAV\CalDAV\CalendarImpl;
use OCA\DAV\CalDAV\CalendarManager; use OCA\DAV\CalDAV\CalendarManager;
use OCP\Calendar\IManager; use OCP\Calendar\IManager;
use OCP\IConfig;
use OCP\IL10N; use OCP\IL10N;
class CalendarManagerTest extends \Test\TestCase { class CalendarManagerTest extends \Test\TestCase {
@ -38,6 +39,9 @@ class CalendarManagerTest extends \Test\TestCase {
/** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */ /** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
private $l10n; private $l10n;
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $config;
/** @var CalendarManager */ /** @var CalendarManager */
private $manager; private $manager;
@ -45,8 +49,9 @@ class CalendarManagerTest extends \Test\TestCase {
parent::setUp(); parent::setUp();
$this->backend = $this->createMock(CalDavBackend::class); $this->backend = $this->createMock(CalDavBackend::class);
$this->l10n = $this->createMock(IL10N::class); $this->l10n = $this->createMock(IL10N::class);
$this->config = $this->createMock(IConfig::class);
$this->manager = new CalendarManager($this->backend, $this->manager = new CalendarManager($this->backend,
$this->l10n); $this->l10n, $this->config);
} }
public function testSetupCalendarProvider() { public function testSetupCalendarProvider() {