2018-06-28 14:07:33 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2018 Georg Ehrke
|
|
|
|
*
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2018-06-28 14:07:33 +03:00
|
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
2018-06-28 14:07:33 +03:00
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2018-06-28 14:07:33 +03:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2019-12-03 21:57:53 +03:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2018-06-28 14:07:33 +03:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-06-28 14:07:33 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\DAV\Tests\unit\CalDAV\WebcalCaching;
|
|
|
|
|
|
|
|
use OCA\DAV\CalDAV\WebcalCaching\Plugin;
|
|
|
|
use OCP\IRequest;
|
|
|
|
|
|
|
|
class PluginTest extends \Test\TestCase {
|
|
|
|
|
|
|
|
public function testDisabled() {
|
|
|
|
$request = $this->createMock(IRequest::class);
|
|
|
|
$request->expects($this->at(0))
|
|
|
|
->method('isUserAgent')
|
|
|
|
->with([])
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn(false);
|
2018-06-28 14:07:33 +03:00
|
|
|
|
|
|
|
$request->expects($this->at(1))
|
|
|
|
->method('getHeader')
|
|
|
|
->with('X-NC-CalDAV-Webcal-Caching')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('');
|
2018-06-28 14:07:33 +03:00
|
|
|
|
|
|
|
$plugin = new Plugin($request);
|
|
|
|
|
|
|
|
$this->assertEquals(false, $plugin->isCachingEnabledForThisRequest());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testEnabled() {
|
|
|
|
$request = $this->createMock(IRequest::class);
|
|
|
|
$request->expects($this->at(0))
|
|
|
|
->method('isUserAgent')
|
|
|
|
->with([])
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn(false);
|
2018-06-28 14:07:33 +03:00
|
|
|
|
|
|
|
$request->expects($this->at(1))
|
|
|
|
->method('getHeader')
|
|
|
|
->with('X-NC-CalDAV-Webcal-Caching')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('On');
|
2018-06-28 14:07:33 +03:00
|
|
|
|
|
|
|
$plugin = new Plugin($request);
|
|
|
|
|
|
|
|
$this->assertEquals(true, $plugin->isCachingEnabledForThisRequest());
|
|
|
|
}
|
|
|
|
}
|