2018-06-19 22:01:14 +03:00
|
|
|
<?php
|
2019-12-03 21:57:53 +03:00
|
|
|
|
2018-06-19 22:01:14 +03:00
|
|
|
declare(strict_types=1);
|
2019-12-03 21:57:53 +03:00
|
|
|
|
2018-06-19 22:01:14 +03:00
|
|
|
/**
|
|
|
|
* @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
|
|
|
|
*
|
2020-03-31 11:49:10 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2018-06-19 22:01:14 +03:00
|
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2020-08-24 15:54:25 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2018-06-19 22:01:14 +03:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2018-06-19 22:01:14 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\DAV\Tests\Unit\DAV\Controller;
|
|
|
|
|
|
|
|
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
|
|
|
|
use OCA\DAV\Controller\InvitationResponseController;
|
|
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
|
|
use OCP\DB\QueryBuilder\IQueryBuilder;
|
|
|
|
use OCP\IDBConnection;
|
|
|
|
use OCP\IRequest;
|
|
|
|
use Sabre\VObject\ITip\Message;
|
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
class InvitationResponseControllerTest extends TestCase {
|
|
|
|
|
|
|
|
/** @var InvitationResponseController */
|
|
|
|
private $controller;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IDBConnection|\PHPUnit\Framework\MockObject\MockObject */
|
2018-06-19 22:01:14 +03:00
|
|
|
private $dbConnection;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
|
2018-06-19 22:01:14 +03:00
|
|
|
private $request;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
|
2018-06-19 22:01:14 +03:00
|
|
|
private $timeFactory;
|
|
|
|
|
2020-08-11 22:32:18 +03:00
|
|
|
/** @var InvitationResponseServer|\PHPUnit\Framework\MockObject\MockObject */
|
2018-06-19 22:01:14 +03:00
|
|
|
private $responseServer;
|
|
|
|
|
2019-11-27 17:27:18 +03:00
|
|
|
protected function setUp(): void {
|
2018-06-19 22:01:14 +03:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->dbConnection = $this->createMock(IDBConnection::class);
|
|
|
|
$this->request = $this->createMock(IRequest::class);
|
|
|
|
$this->timeFactory = $this->createMock(ITimeFactory::class);
|
|
|
|
$this->responseServer = $this->getMockBuilder(InvitationResponseServer::class)
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
$this->controller = new InvitationResponseController(
|
|
|
|
'appName',
|
|
|
|
$this->request,
|
|
|
|
$this->dbConnection,
|
|
|
|
$this->timeFactory,
|
|
|
|
$this->responseServer
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAccept() {
|
|
|
|
$this->buildQueryExpects('TOKEN123', [
|
|
|
|
'id' => 0,
|
|
|
|
'uid' => 'this-is-the-events-uid',
|
|
|
|
'recurrenceid' => null,
|
|
|
|
'attendee' => 'mailto:attendee@foo.bar',
|
|
|
|
'organizer' => 'mailto:organizer@foo.bar',
|
|
|
|
'sequence' => null,
|
|
|
|
'token' => 'TOKEN123',
|
|
|
|
'expiration' => 420000,
|
|
|
|
], 1337);
|
|
|
|
|
|
|
|
$expected = <<<EOF
|
|
|
|
BEGIN:VCALENDAR
|
|
|
|
VERSION:2.0
|
|
|
|
PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
|
|
|
|
METHOD:REPLY
|
|
|
|
BEGIN:VEVENT
|
|
|
|
ATTENDEE;PARTSTAT=ACCEPTED:mailto:attendee@foo.bar
|
|
|
|
ORGANIZER:mailto:organizer@foo.bar
|
|
|
|
UID:this-is-the-events-uid
|
|
|
|
SEQUENCE:0
|
|
|
|
REQUEST-STATUS:2.0;Success
|
|
|
|
DTSTAMP:19700101T002217Z
|
|
|
|
END:VEVENT
|
|
|
|
END:VCALENDAR
|
|
|
|
|
|
|
|
EOF;
|
|
|
|
$expected = preg_replace('~\R~u', "\r\n", $expected);
|
|
|
|
|
|
|
|
$called = false;
|
|
|
|
$this->responseServer->expects($this->once())
|
|
|
|
->method('handleITipMessage')
|
2020-04-09 14:53:40 +03:00
|
|
|
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
|
2018-06-19 22:01:14 +03:00
|
|
|
$called = true;
|
|
|
|
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
|
|
|
|
$this->assertEquals('VEVENT', $iTipMessage->component);
|
|
|
|
$this->assertEquals('REPLY', $iTipMessage->method);
|
|
|
|
$this->assertEquals(null, $iTipMessage->sequence);
|
|
|
|
$this->assertEquals('mailto:attendee@foo.bar', $iTipMessage->sender);
|
|
|
|
$this->assertEquals('mailto:organizer@foo.bar', $iTipMessage->recipient);
|
|
|
|
|
|
|
|
$iTipMessage->scheduleStatus = '1.2;Message delivered locally';
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $iTipMessage->message->serialize());
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->controller->accept('TOKEN123');
|
|
|
|
$this->assertInstanceOf(TemplateResponse::class, $response);
|
|
|
|
$this->assertEquals('schedule-response-success', $response->getTemplateName());
|
|
|
|
$this->assertEquals([], $response->getParams());
|
|
|
|
$this->assertTrue($called);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAcceptSequence() {
|
|
|
|
$this->buildQueryExpects('TOKEN123', [
|
|
|
|
'id' => 0,
|
|
|
|
'uid' => 'this-is-the-events-uid',
|
|
|
|
'recurrenceid' => null,
|
|
|
|
'attendee' => 'mailto:attendee@foo.bar',
|
|
|
|
'organizer' => 'mailto:organizer@foo.bar',
|
|
|
|
'sequence' => 1337,
|
|
|
|
'token' => 'TOKEN123',
|
|
|
|
'expiration' => 420000,
|
|
|
|
], 1337);
|
|
|
|
|
|
|
|
$expected = <<<EOF
|
|
|
|
BEGIN:VCALENDAR
|
|
|
|
VERSION:2.0
|
|
|
|
PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
|
|
|
|
METHOD:REPLY
|
|
|
|
BEGIN:VEVENT
|
|
|
|
ATTENDEE;PARTSTAT=ACCEPTED:mailto:attendee@foo.bar
|
|
|
|
ORGANIZER:mailto:organizer@foo.bar
|
|
|
|
UID:this-is-the-events-uid
|
|
|
|
SEQUENCE:1337
|
|
|
|
REQUEST-STATUS:2.0;Success
|
|
|
|
DTSTAMP:19700101T002217Z
|
|
|
|
END:VEVENT
|
|
|
|
END:VCALENDAR
|
|
|
|
|
|
|
|
EOF;
|
|
|
|
$expected = preg_replace('~\R~u', "\r\n", $expected);
|
|
|
|
|
|
|
|
$called = false;
|
|
|
|
$this->responseServer->expects($this->once())
|
|
|
|
->method('handleITipMessage')
|
2020-04-09 14:53:40 +03:00
|
|
|
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
|
2018-06-19 22:01:14 +03:00
|
|
|
$called = true;
|
|
|
|
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
|
|
|
|
$this->assertEquals('VEVENT', $iTipMessage->component);
|
|
|
|
$this->assertEquals('REPLY', $iTipMessage->method);
|
|
|
|
$this->assertEquals(1337, $iTipMessage->sequence);
|
|
|
|
$this->assertEquals('mailto:attendee@foo.bar', $iTipMessage->sender);
|
|
|
|
$this->assertEquals('mailto:organizer@foo.bar', $iTipMessage->recipient);
|
|
|
|
|
|
|
|
$iTipMessage->scheduleStatus = '1.2;Message delivered locally';
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $iTipMessage->message->serialize());
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->controller->accept('TOKEN123');
|
|
|
|
$this->assertInstanceOf(TemplateResponse::class, $response);
|
|
|
|
$this->assertEquals('schedule-response-success', $response->getTemplateName());
|
|
|
|
$this->assertEquals([], $response->getParams());
|
|
|
|
$this->assertTrue($called);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAcceptRecurrenceId() {
|
|
|
|
$this->buildQueryExpects('TOKEN123', [
|
|
|
|
'id' => 0,
|
|
|
|
'uid' => 'this-is-the-events-uid',
|
|
|
|
'recurrenceid' => "RECURRENCE-ID;TZID=Europe/Berlin:20180726T150000\n",
|
|
|
|
'attendee' => 'mailto:attendee@foo.bar',
|
|
|
|
'organizer' => 'mailto:organizer@foo.bar',
|
|
|
|
'sequence' => null,
|
|
|
|
'token' => 'TOKEN123',
|
|
|
|
'expiration' => 420000,
|
|
|
|
], 1337);
|
|
|
|
|
|
|
|
$expected = <<<EOF
|
|
|
|
BEGIN:VCALENDAR
|
|
|
|
VERSION:2.0
|
|
|
|
PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
|
|
|
|
METHOD:REPLY
|
|
|
|
BEGIN:VEVENT
|
|
|
|
ATTENDEE;PARTSTAT=ACCEPTED:mailto:attendee@foo.bar
|
|
|
|
ORGANIZER:mailto:organizer@foo.bar
|
|
|
|
UID:this-is-the-events-uid
|
|
|
|
SEQUENCE:0
|
|
|
|
REQUEST-STATUS:2.0;Success
|
|
|
|
RECURRENCE-ID;TZID=Europe/Berlin:20180726T150000
|
|
|
|
DTSTAMP:19700101T002217Z
|
|
|
|
END:VEVENT
|
|
|
|
END:VCALENDAR
|
|
|
|
|
|
|
|
EOF;
|
|
|
|
$expected = preg_replace('~\R~u', "\r\n", $expected);
|
|
|
|
|
|
|
|
$called = false;
|
|
|
|
$this->responseServer->expects($this->once())
|
|
|
|
->method('handleITipMessage')
|
2020-04-09 14:53:40 +03:00
|
|
|
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
|
2018-06-19 22:01:14 +03:00
|
|
|
$called = true;
|
|
|
|
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
|
|
|
|
$this->assertEquals('VEVENT', $iTipMessage->component);
|
|
|
|
$this->assertEquals('REPLY', $iTipMessage->method);
|
|
|
|
$this->assertEquals(0, $iTipMessage->sequence);
|
|
|
|
$this->assertEquals('mailto:attendee@foo.bar', $iTipMessage->sender);
|
|
|
|
$this->assertEquals('mailto:organizer@foo.bar', $iTipMessage->recipient);
|
|
|
|
|
|
|
|
$iTipMessage->scheduleStatus = '1.2;Message delivered locally';
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $iTipMessage->message->serialize());
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->controller->accept('TOKEN123');
|
|
|
|
$this->assertInstanceOf(TemplateResponse::class, $response);
|
|
|
|
$this->assertEquals('schedule-response-success', $response->getTemplateName());
|
|
|
|
$this->assertEquals([], $response->getParams());
|
|
|
|
$this->assertTrue($called);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAcceptTokenNotFound() {
|
|
|
|
$this->buildQueryExpects('TOKEN123', null, 1337);
|
|
|
|
|
|
|
|
$response = $this->controller->accept('TOKEN123');
|
|
|
|
$this->assertInstanceOf(TemplateResponse::class, $response);
|
|
|
|
$this->assertEquals('schedule-response-error', $response->getTemplateName());
|
|
|
|
$this->assertEquals([], $response->getParams());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testAcceptExpiredToken() {
|
|
|
|
$this->buildQueryExpects('TOKEN123', [
|
|
|
|
'id' => 0,
|
|
|
|
'uid' => 'this-is-the-events-uid',
|
|
|
|
'recurrenceid' => null,
|
|
|
|
'attendee' => 'mailto:attendee@foo.bar',
|
|
|
|
'organizer' => 'mailto:organizer@foo.bar',
|
|
|
|
'sequence' => null,
|
|
|
|
'token' => 'TOKEN123',
|
|
|
|
'expiration' => 42,
|
|
|
|
], 1337);
|
|
|
|
|
|
|
|
$response = $this->controller->accept('TOKEN123');
|
|
|
|
$this->assertInstanceOf(TemplateResponse::class, $response);
|
|
|
|
$this->assertEquals('schedule-response-error', $response->getTemplateName());
|
|
|
|
$this->assertEquals([], $response->getParams());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDecline() {
|
|
|
|
$this->buildQueryExpects('TOKEN123', [
|
|
|
|
'id' => 0,
|
|
|
|
'uid' => 'this-is-the-events-uid',
|
|
|
|
'recurrenceid' => null,
|
|
|
|
'attendee' => 'mailto:attendee@foo.bar',
|
|
|
|
'organizer' => 'mailto:organizer@foo.bar',
|
|
|
|
'sequence' => null,
|
|
|
|
'token' => 'TOKEN123',
|
|
|
|
'expiration' => 420000,
|
|
|
|
], 1337);
|
|
|
|
|
|
|
|
$expected = <<<EOF
|
|
|
|
BEGIN:VCALENDAR
|
|
|
|
VERSION:2.0
|
|
|
|
PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
|
|
|
|
METHOD:REPLY
|
|
|
|
BEGIN:VEVENT
|
|
|
|
ATTENDEE;PARTSTAT=DECLINED:mailto:attendee@foo.bar
|
|
|
|
ORGANIZER:mailto:organizer@foo.bar
|
|
|
|
UID:this-is-the-events-uid
|
|
|
|
SEQUENCE:0
|
|
|
|
REQUEST-STATUS:2.0;Success
|
|
|
|
DTSTAMP:19700101T002217Z
|
|
|
|
END:VEVENT
|
|
|
|
END:VCALENDAR
|
|
|
|
|
|
|
|
EOF;
|
|
|
|
$expected = preg_replace('~\R~u', "\r\n", $expected);
|
|
|
|
|
|
|
|
$called = false;
|
|
|
|
$this->responseServer->expects($this->once())
|
|
|
|
->method('handleITipMessage')
|
2020-04-09 14:53:40 +03:00
|
|
|
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
|
2018-06-19 22:01:14 +03:00
|
|
|
$called = true;
|
|
|
|
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
|
|
|
|
$this->assertEquals('VEVENT', $iTipMessage->component);
|
|
|
|
$this->assertEquals('REPLY', $iTipMessage->method);
|
|
|
|
$this->assertEquals(null, $iTipMessage->sequence);
|
|
|
|
$this->assertEquals('mailto:attendee@foo.bar', $iTipMessage->sender);
|
|
|
|
$this->assertEquals('mailto:organizer@foo.bar', $iTipMessage->recipient);
|
|
|
|
|
|
|
|
$iTipMessage->scheduleStatus = '1.2;Message delivered locally';
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $iTipMessage->message->serialize());
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->controller->decline('TOKEN123');
|
|
|
|
$this->assertInstanceOf(TemplateResponse::class, $response);
|
|
|
|
$this->assertEquals('schedule-response-success', $response->getTemplateName());
|
|
|
|
$this->assertEquals([], $response->getParams());
|
|
|
|
$this->assertTrue($called);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOptions() {
|
|
|
|
$response = $this->controller->options('TOKEN123');
|
|
|
|
$this->assertInstanceOf(TemplateResponse::class, $response);
|
|
|
|
$this->assertEquals('schedule-response-options', $response->getTemplateName());
|
|
|
|
$this->assertEquals(['token' => 'TOKEN123'], $response->getParams());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testProcessMoreOptionsResult() {
|
|
|
|
$this->request->expects($this->at(0))
|
|
|
|
->method('getParam')
|
|
|
|
->with('partStat')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('TENTATIVE');
|
2018-06-19 22:01:14 +03:00
|
|
|
$this->request->expects($this->at(1))
|
|
|
|
->method('getParam')
|
|
|
|
->with('guests')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('7');
|
2018-06-19 22:01:14 +03:00
|
|
|
$this->request->expects($this->at(2))
|
|
|
|
->method('getParam')
|
|
|
|
->with('comment')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('Foo bar Bli blub');
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
$this->buildQueryExpects('TOKEN123', [
|
|
|
|
'id' => 0,
|
|
|
|
'uid' => 'this-is-the-events-uid',
|
|
|
|
'recurrenceid' => null,
|
|
|
|
'attendee' => 'mailto:attendee@foo.bar',
|
|
|
|
'organizer' => 'mailto:organizer@foo.bar',
|
|
|
|
'sequence' => null,
|
|
|
|
'token' => 'TOKEN123',
|
|
|
|
'expiration' => 420000,
|
|
|
|
], 1337);
|
|
|
|
|
|
|
|
$expected = <<<EOF
|
|
|
|
BEGIN:VCALENDAR
|
|
|
|
VERSION:2.0
|
|
|
|
PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
|
|
|
|
METHOD:REPLY
|
|
|
|
BEGIN:VEVENT
|
|
|
|
ATTENDEE;PARTSTAT=TENTATIVE;X-RESPONSE-COMMENT=Foo bar Bli blub;X-NUM-GUEST
|
|
|
|
S=7:mailto:attendee@foo.bar
|
|
|
|
ORGANIZER:mailto:organizer@foo.bar
|
|
|
|
UID:this-is-the-events-uid
|
|
|
|
SEQUENCE:0
|
|
|
|
REQUEST-STATUS:2.0;Success
|
|
|
|
DTSTAMP:19700101T002217Z
|
|
|
|
COMMENT:Foo bar Bli blub
|
|
|
|
END:VEVENT
|
|
|
|
END:VCALENDAR
|
|
|
|
|
|
|
|
EOF;
|
|
|
|
$expected = preg_replace('~\R~u', "\r\n", $expected);
|
|
|
|
|
|
|
|
$called = false;
|
|
|
|
$this->responseServer->expects($this->once())
|
|
|
|
->method('handleITipMessage')
|
2020-04-09 14:53:40 +03:00
|
|
|
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
|
2018-06-19 22:01:14 +03:00
|
|
|
$called = true;
|
|
|
|
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
|
|
|
|
$this->assertEquals('VEVENT', $iTipMessage->component);
|
|
|
|
$this->assertEquals('REPLY', $iTipMessage->method);
|
|
|
|
$this->assertEquals(null, $iTipMessage->sequence);
|
|
|
|
$this->assertEquals('mailto:attendee@foo.bar', $iTipMessage->sender);
|
|
|
|
$this->assertEquals('mailto:organizer@foo.bar', $iTipMessage->recipient);
|
|
|
|
|
|
|
|
$iTipMessage->scheduleStatus = '1.2;Message delivered locally';
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $iTipMessage->message->serialize());
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$response = $this->controller->processMoreOptionsResult('TOKEN123');
|
|
|
|
$this->assertInstanceOf(TemplateResponse::class, $response);
|
|
|
|
$this->assertEquals('schedule-response-success', $response->getTemplateName());
|
|
|
|
$this->assertEquals([], $response->getParams());
|
|
|
|
$this->assertTrue($called);
|
|
|
|
}
|
|
|
|
|
|
|
|
private function buildQueryExpects($token, $return, $time) {
|
|
|
|
$queryBuilder = $this->createMock(IQueryBuilder::class);
|
|
|
|
$stmt = $this->createMock(\Doctrine\DBAL\Driver\Statement::class);
|
|
|
|
$expr = $this->createMock(\OCP\DB\QueryBuilder\IExpressionBuilder::class);
|
|
|
|
|
|
|
|
$this->dbConnection->expects($this->once())
|
|
|
|
->method('getQueryBuilder')
|
|
|
|
->with()
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($queryBuilder);
|
2018-06-19 22:01:14 +03:00
|
|
|
$queryBuilder->method('expr')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($expr);
|
2018-06-19 22:01:14 +03:00
|
|
|
$queryBuilder->method('createNamedParameter')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnMap([
|
2018-06-19 22:01:14 +03:00
|
|
|
[$token, \PDO::PARAM_STR, null, 'namedParameterToken']
|
2020-03-26 00:21:27 +03:00
|
|
|
]);
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
$stmt->expects($this->once())
|
|
|
|
->method('fetch')
|
|
|
|
->with(\PDO::FETCH_ASSOC)
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($return);
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
$expr->expects($this->once())
|
|
|
|
->method('eq')
|
|
|
|
->with('token', 'namedParameterToken')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('EQ STATEMENT');
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
$this->dbConnection->expects($this->once())
|
|
|
|
->method('getQueryBuilder')
|
|
|
|
->with()
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($queryBuilder);
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
$queryBuilder->expects($this->at(0))
|
|
|
|
->method('select')
|
|
|
|
->with('*')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($queryBuilder);
|
2018-06-19 22:01:14 +03:00
|
|
|
$queryBuilder->expects($this->at(1))
|
|
|
|
->method('from')
|
2018-07-12 13:11:11 +03:00
|
|
|
->with('calendar_invitations')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($queryBuilder);
|
2018-06-19 22:01:14 +03:00
|
|
|
$queryBuilder->expects($this->at(4))
|
|
|
|
->method('where')
|
|
|
|
->with('EQ STATEMENT')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($queryBuilder);
|
2018-06-19 22:01:14 +03:00
|
|
|
$queryBuilder->expects($this->at(5))
|
|
|
|
->method('execute')
|
|
|
|
->with()
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($stmt);
|
2018-06-19 22:01:14 +03:00
|
|
|
|
|
|
|
$this->timeFactory->method('getTime')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn($time);
|
2018-06-19 22:01:14 +03:00
|
|
|
}
|
2018-07-12 13:11:11 +03:00
|
|
|
}
|