2018-06-19 13:22:30 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2018, Georg Ehrke
|
|
|
|
*
|
|
|
|
* @author Georg Ehrke <oc.list@georgehrke.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2018-06-19 13:22:30 +03:00
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
2018-06-19 13:22:30 +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-19 13:22:30 +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-19 13:22:30 +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-19 13:22:30 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\DAV\Tests\unit\BackgroundJob;
|
|
|
|
|
|
|
|
use OCA\DAV\BackgroundJob\UpdateCalendarResourcesRoomsBackgroundJob;
|
|
|
|
|
|
|
|
use OCA\DAV\CalDAV\CalDavBackend;
|
|
|
|
use OCP\Calendar\BackendTemporarilyUnavailableException;
|
2019-08-01 15:03:34 +03:00
|
|
|
use OCP\Calendar\IMetadataProvider;
|
2018-06-19 13:22:30 +03:00
|
|
|
use OCP\Calendar\Resource\IBackend;
|
|
|
|
use OCP\Calendar\Resource\IManager as IResourceManager;
|
|
|
|
use OCP\Calendar\Resource\IResource;
|
|
|
|
use OCP\Calendar\Room\IManager as IRoomManager;
|
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
class UpdateCalendarResourcesRoomsBackgroundJobTest extends TestCase {
|
|
|
|
|
|
|
|
/** @var UpdateCalendarResourcesRoomsBackgroundJob */
|
|
|
|
private $backgroundJob;
|
|
|
|
|
|
|
|
/** @var IResourceManager | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $resourceManager;
|
|
|
|
|
|
|
|
/** @var IRoomManager | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $roomManager;
|
|
|
|
|
|
|
|
/** @var CalDavBackend | \PHPUnit_Framework_MockObject_MockObject */
|
|
|
|
private $calDavBackend;
|
|
|
|
|
2019-11-21 18:40:38 +03:00
|
|
|
protected function setUp(): void {
|
2018-06-19 13:22:30 +03:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->resourceManager = $this->createMock(IResourceManager::class);
|
|
|
|
$this->roomManager = $this->createMock(IRoomManager::class);
|
|
|
|
$this->calDavBackend = $this->createMock(CalDavBackend::class);
|
|
|
|
|
|
|
|
$this->backgroundJob = new UpdateCalendarResourcesRoomsBackgroundJob(
|
|
|
|
$this->resourceManager, $this->roomManager, self::$realDatabase,
|
|
|
|
$this->calDavBackend);
|
|
|
|
}
|
|
|
|
|
2019-11-21 18:40:38 +03:00
|
|
|
protected function tearDown(): void {
|
2018-06-19 13:22:30 +03:00
|
|
|
$query = self::$realDatabase->getQueryBuilder();
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->delete('calendar_resources')->execute();
|
2019-08-01 15:03:34 +03:00
|
|
|
$query->delete('calendar_resources_md')->execute();
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->delete('calendar_rooms')->execute();
|
2019-08-01 15:03:34 +03:00
|
|
|
$query->delete('calendar_rooms_md')->execute();
|
2018-06-19 13:22:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data in Cache:
|
|
|
|
* resources:
|
2019-08-01 15:03:34 +03:00
|
|
|
* [backend1, res1, Beamer1, {}] - []
|
|
|
|
* [backend1, res2, TV1, {}] - []
|
|
|
|
* [backend2, res3, Beamer2, {}] - ['meta1' => 'value1', 'meta2' => 'value2']
|
|
|
|
* [backend2, res4, TV2, {}] - ['meta1' => 'value1', 'meta3' => 'value3-old']
|
|
|
|
* [backend3, res5, Beamer3, {}] - []
|
|
|
|
* [backend3, res6, Pointer, {foo, bar}] - ['meta99' => 'value99']
|
2018-06-19 13:22:30 +03:00
|
|
|
*
|
|
|
|
* Data in Backend:
|
|
|
|
* backend1 gone
|
|
|
|
* backend2 throws BackendTemporarilyUnavailableException
|
2019-08-01 15:03:34 +03:00
|
|
|
* [backend3, res6, Pointer123, {foo, biz}] - ['meta99' => 'value99-new', 'meta123' => 'meta456']
|
|
|
|
* [backend3, res7, Resource4, {biz}] - ['meta1' => 'value1']
|
|
|
|
* [backend4, res8, Beamer, {}] - ['meta2' => 'value2']
|
|
|
|
* [backend4, res9, Beamer2, {}] - []
|
2018-06-19 13:22:30 +03:00
|
|
|
*
|
|
|
|
* Expected after run:
|
2019-08-01 15:03:34 +03:00
|
|
|
* [backend1, res1, Beamer1, {}] - []
|
|
|
|
* [backend1, res2, TV1, {}] - []
|
|
|
|
* [backend2, res3, Beamer2, {}] - ['meta1' => 'value1', 'meta2' => 'value2']
|
|
|
|
* [backend2, res4, TV2, {}] - ['meta1' => 'value1', 'meta3' => 'value3-old']
|
|
|
|
* [backend3, res6, Pointer123, {foo, biz}] - ['meta99' => 'value99-new', 'meta123' => 'meta456']
|
|
|
|
* [backend3, res7, Resource4, {biz}] - ['meta1' => 'value1']
|
|
|
|
* [backend4, res8, Beamer, {}] - ['meta2' => 'value2']
|
|
|
|
* [backend4, res9, Beamer2, {}] - []
|
2018-06-19 13:22:30 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
public function testRun() {
|
|
|
|
$this->createTestResourcesInCache();
|
|
|
|
|
|
|
|
$backend2 = $this->createMock(IBackend::class);
|
|
|
|
$backend3 = $this->createMock(IBackend::class);
|
|
|
|
$backend4 = $this->createMock(IBackend::class);
|
|
|
|
|
2019-08-01 15:03:34 +03:00
|
|
|
$res6 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
|
|
|
$res7 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
|
|
|
$res8 = $this->createMock([IResource::class, IMetadataProvider::class]);
|
2018-06-19 13:22:30 +03:00
|
|
|
$res9 = $this->createMock(IResource::class);
|
|
|
|
|
|
|
|
$backend2->method('getBackendIdentifier')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('backend2');
|
2018-06-19 13:22:30 +03:00
|
|
|
$backend2->method('listAllResources')
|
|
|
|
->will($this->throwException(new BackendTemporarilyUnavailableException()));
|
|
|
|
$backend2->method('getResource')
|
|
|
|
->will($this->throwException(new BackendTemporarilyUnavailableException()));
|
|
|
|
$backend2->method('getAllResources')
|
|
|
|
->will($this->throwException(new BackendTemporarilyUnavailableException()));
|
|
|
|
$backend3->method('getBackendIdentifier')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('backend3');
|
2018-06-19 13:22:30 +03:00
|
|
|
$backend3->method('listAllResources')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn(['res6', 'res7']);
|
2018-06-19 13:22:30 +03:00
|
|
|
$backend3->method('getResource')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnMap([
|
2018-06-19 13:22:30 +03:00
|
|
|
['res6', $res6],
|
|
|
|
['res7', $res7],
|
2020-03-26 00:21:27 +03:00
|
|
|
]);
|
2018-06-19 13:22:30 +03:00
|
|
|
$backend4->method('getBackendIdentifier')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn('backend4');
|
2018-06-19 13:22:30 +03:00
|
|
|
$backend4->method('listAllResources')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn(['res8', 'res9']);
|
2018-06-19 13:22:30 +03:00
|
|
|
$backend4->method('getResource')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnMap([
|
2018-06-19 13:22:30 +03:00
|
|
|
['res8', $res8],
|
|
|
|
['res9', $res9],
|
2020-03-26 00:21:27 +03:00
|
|
|
]);
|
2018-06-19 13:22:30 +03:00
|
|
|
|
2020-03-26 00:21:27 +03:00
|
|
|
$res6->method('getId')->willReturn('res6');
|
|
|
|
$res6->method('getDisplayName')->willReturn('Pointer123');
|
|
|
|
$res6->method('getGroupRestrictions')->willReturn(['foo', 'biz']);
|
|
|
|
$res6->method('getEMail')->willReturn('res6@foo.bar');
|
|
|
|
$res6->method('getBackend')->willReturn($backend3);
|
2018-06-19 13:22:30 +03:00
|
|
|
|
2020-03-26 00:21:27 +03:00
|
|
|
$res6->method('getAllAvailableMetadataKeys')->willReturn(['meta99', 'meta123']);
|
|
|
|
$res6->method('getMetadataForKey')->willReturnCallback(function($key) {
|
2019-08-01 15:03:34 +03:00
|
|
|
switch($key) {
|
|
|
|
case 'meta99':
|
|
|
|
return 'value99-new';
|
|
|
|
|
|
|
|
case 'meta123':
|
|
|
|
return 'meta456';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
$res7->method('getId')->willReturn('res7');
|
|
|
|
$res7->method('getDisplayName')->willReturn('Resource4');
|
|
|
|
$res7->method('getGroupRestrictions')->willReturn(['biz']);
|
|
|
|
$res7->method('getEMail')->willReturn('res7@foo.bar');
|
|
|
|
$res7->method('getBackend')->willReturn($backend3);
|
|
|
|
$res7->method('getAllAvailableMetadataKeys')->willReturn(['meta1']);
|
|
|
|
$res7->method('getMetadataForKey')->willReturnCallback(function($key) {
|
2019-08-01 15:03:34 +03:00
|
|
|
switch($key) {
|
|
|
|
case 'meta1':
|
|
|
|
return 'value1';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
$res8->method('getId')->willReturn('res8');
|
|
|
|
$res8->method('getDisplayName')->willReturn('Beamer');
|
|
|
|
$res8->method('getGroupRestrictions')->willReturn([]);
|
|
|
|
$res8->method('getEMail')->willReturn('res8@foo.bar');
|
|
|
|
$res8->method('getBackend')->willReturn($backend4);
|
|
|
|
$res8->method('getAllAvailableMetadataKeys')->willReturn(['meta2']);
|
|
|
|
$res8->method('getMetadataForKey')->willReturnCallback(function($key) {
|
2019-08-01 15:03:34 +03:00
|
|
|
switch($key) {
|
|
|
|
case 'meta2':
|
|
|
|
return 'value2';
|
|
|
|
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
2020-03-26 00:21:27 +03:00
|
|
|
});
|
2018-06-19 13:22:30 +03:00
|
|
|
|
2020-03-26 00:21:27 +03:00
|
|
|
$res9->method('getId')->willReturn('res9');
|
|
|
|
$res9->method('getDisplayName')->willReturn('Beamer2');
|
|
|
|
$res9->method('getGroupRestrictions')->willReturn([]);
|
|
|
|
$res9->method('getEMail')->willReturn('res9@foo.bar');
|
|
|
|
$res9->method('getBackend')->willReturn($backend4);
|
2018-06-19 13:22:30 +03:00
|
|
|
|
|
|
|
$this->resourceManager
|
|
|
|
->method('getBackends')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturn([
|
2018-06-19 13:22:30 +03:00
|
|
|
$backend2, $backend3, $backend4
|
2020-03-26 00:21:27 +03:00
|
|
|
]);
|
2018-06-19 13:22:30 +03:00
|
|
|
$this->resourceManager
|
|
|
|
->method('getBackend')
|
2020-03-26 00:21:27 +03:00
|
|
|
->willReturnMap([
|
2018-06-19 13:22:30 +03:00
|
|
|
['backend2', $backend2],
|
|
|
|
['backend3', $backend3],
|
|
|
|
['backend4', $backend4],
|
2020-03-26 00:21:27 +03:00
|
|
|
]);
|
2018-06-19 13:22:30 +03:00
|
|
|
|
|
|
|
$this->backgroundJob->run([]);
|
|
|
|
|
|
|
|
$query = self::$realDatabase->getQueryBuilder();
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->select('*')->from('calendar_resources');
|
2018-06-19 13:22:30 +03:00
|
|
|
|
|
|
|
$rows = [];
|
2019-08-01 15:03:34 +03:00
|
|
|
$ids = [];
|
2018-06-19 13:22:30 +03:00
|
|
|
$stmt = $query->execute();
|
|
|
|
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
2019-08-01 15:03:34 +03:00
|
|
|
$ids[$row['backend_id'] . '::' . $row['resource_id']] = $row['id'];
|
2018-06-19 13:22:30 +03:00
|
|
|
unset($row['id']);
|
|
|
|
$rows[] = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertEquals([
|
2019-08-01 15:03:34 +03:00
|
|
|
[
|
|
|
|
'backend_id' => 'backend1',
|
|
|
|
'resource_id' => 'res1',
|
|
|
|
'displayname' => 'Beamer1',
|
|
|
|
'email' => 'res1@foo.bar',
|
|
|
|
'group_restrictions' => '[]',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'backend_id' => 'backend1',
|
|
|
|
'resource_id' => 'res2',
|
|
|
|
'displayname' => 'TV1',
|
|
|
|
'email' => 'res2@foo.bar',
|
|
|
|
'group_restrictions' => '[]',
|
|
|
|
],
|
2018-06-19 13:22:30 +03:00
|
|
|
[
|
|
|
|
'backend_id' => 'backend2',
|
|
|
|
'resource_id' => 'res3',
|
|
|
|
'displayname' => 'Beamer2',
|
|
|
|
'email' => 'res3@foo.bar',
|
|
|
|
'group_restrictions' => '[]',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'backend_id' => 'backend2',
|
|
|
|
'resource_id' => 'res4',
|
|
|
|
'displayname' => 'TV2',
|
|
|
|
'email' => 'res4@foo.bar',
|
|
|
|
'group_restrictions' => '[]',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'backend_id' => 'backend3',
|
|
|
|
'resource_id' => 'res6',
|
|
|
|
'displayname' => 'Pointer123',
|
|
|
|
'email' => 'res6@foo.bar',
|
|
|
|
'group_restrictions' => '["foo","biz"]',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'backend_id' => 'backend3',
|
|
|
|
'resource_id' => 'res7',
|
|
|
|
'displayname' => 'Resource4',
|
|
|
|
'email' => 'res7@foo.bar',
|
|
|
|
'group_restrictions' => '["biz"]',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'backend_id' => 'backend4',
|
|
|
|
'resource_id' => 'res8',
|
|
|
|
'displayname' => 'Beamer',
|
|
|
|
'email' => 'res8@foo.bar',
|
|
|
|
'group_restrictions' => '[]',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'backend_id' => 'backend4',
|
|
|
|
'resource_id' => 'res9',
|
|
|
|
'displayname' => 'Beamer2',
|
|
|
|
'email' => 'res9@foo.bar',
|
|
|
|
'group_restrictions' => '[]',
|
|
|
|
],
|
|
|
|
], $rows);
|
2019-08-01 15:03:34 +03:00
|
|
|
|
|
|
|
$query2 = self::$realDatabase->getQueryBuilder();
|
|
|
|
$query2->select('*')->from('calendar_resources_md');
|
|
|
|
|
|
|
|
$rows2 = [];
|
|
|
|
$stmt = $query2->execute();
|
|
|
|
while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
|
|
|
|
unset($row['id']);
|
|
|
|
$rows2[] = $row;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
[
|
|
|
|
'resource_id' => $ids['backend2::res3'],
|
|
|
|
'key' => 'meta1',
|
|
|
|
'value' => 'value1',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'resource_id' => $ids['backend2::res3'],
|
|
|
|
'key' => 'meta2',
|
|
|
|
'value' => 'value2',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'resource_id' => $ids['backend2::res4'],
|
|
|
|
'key' => 'meta1',
|
|
|
|
'value' => 'value1',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'resource_id' => $ids['backend2::res4'],
|
|
|
|
'key' => 'meta3',
|
|
|
|
'value' => 'value3-old',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'resource_id' => $ids['backend3::res6'],
|
|
|
|
'key' => 'meta99',
|
|
|
|
'value' => 'value99-new',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'resource_id' => $ids['backend3::res7'],
|
|
|
|
'key' => 'meta1',
|
|
|
|
'value' => 'value1',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'resource_id' => $ids['backend3::res6'],
|
|
|
|
'key' => 'meta123',
|
|
|
|
'value' => 'meta456',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'resource_id' => $ids['backend4::res8'],
|
|
|
|
'key' => 'meta2',
|
|
|
|
'value' => 'value2',
|
|
|
|
]
|
|
|
|
], $rows2);
|
2018-06-19 13:22:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function createTestResourcesInCache() {
|
|
|
|
$query = self::$realDatabase->getQueryBuilder();
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->insert('calendar_resources')
|
2018-06-19 13:22:30 +03:00
|
|
|
->values([
|
|
|
|
'backend_id' => $query->createNamedParameter('backend1'),
|
|
|
|
'resource_id' => $query->createNamedParameter('res1'),
|
|
|
|
'email' => $query->createNamedParameter('res1@foo.bar'),
|
|
|
|
'displayname' => $query->createNamedParameter('Beamer1'),
|
|
|
|
'group_restrictions' => $query->createNamedParameter('[]'),
|
|
|
|
])
|
|
|
|
->execute();
|
2019-08-01 15:03:34 +03:00
|
|
|
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->insert('calendar_resources')
|
2018-06-19 13:22:30 +03:00
|
|
|
->values([
|
|
|
|
'backend_id' => $query->createNamedParameter('backend1'),
|
|
|
|
'resource_id' => $query->createNamedParameter('res2'),
|
|
|
|
'email' => $query->createNamedParameter('res2@foo.bar'),
|
|
|
|
'displayname' => $query->createNamedParameter('TV1'),
|
|
|
|
'group_restrictions' => $query->createNamedParameter('[]'),
|
|
|
|
])
|
|
|
|
->execute();
|
2019-08-01 15:03:34 +03:00
|
|
|
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->insert('calendar_resources')
|
2018-06-19 13:22:30 +03:00
|
|
|
->values([
|
|
|
|
'backend_id' => $query->createNamedParameter('backend2'),
|
|
|
|
'resource_id' => $query->createNamedParameter('res3'),
|
|
|
|
'email' => $query->createNamedParameter('res3@foo.bar'),
|
|
|
|
'displayname' => $query->createNamedParameter('Beamer2'),
|
|
|
|
'group_restrictions' => $query->createNamedParameter('[]'),
|
|
|
|
])
|
|
|
|
->execute();
|
2019-08-01 15:03:34 +03:00
|
|
|
$id3 = $query->getLastInsertId();
|
|
|
|
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->insert('calendar_resources')
|
2018-06-19 13:22:30 +03:00
|
|
|
->values([
|
|
|
|
'backend_id' => $query->createNamedParameter('backend2'),
|
|
|
|
'resource_id' => $query->createNamedParameter('res4'),
|
|
|
|
'email' => $query->createNamedParameter('res4@foo.bar'),
|
|
|
|
'displayname' => $query->createNamedParameter('TV2'),
|
|
|
|
'group_restrictions' => $query->createNamedParameter('[]'),
|
|
|
|
])
|
|
|
|
->execute();
|
2019-08-01 15:03:34 +03:00
|
|
|
$id4 = $query->getLastInsertId();
|
|
|
|
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->insert('calendar_resources')
|
2018-06-19 13:22:30 +03:00
|
|
|
->values([
|
|
|
|
'backend_id' => $query->createNamedParameter('backend3'),
|
|
|
|
'resource_id' => $query->createNamedParameter('res5'),
|
|
|
|
'email' => $query->createNamedParameter('res5@foo.bar'),
|
|
|
|
'displayname' => $query->createNamedParameter('Beamer3'),
|
|
|
|
'group_restrictions' => $query->createNamedParameter('[]'),
|
|
|
|
])
|
|
|
|
->execute();
|
2019-08-01 15:03:34 +03:00
|
|
|
|
2018-07-12 12:55:19 +03:00
|
|
|
$query->insert('calendar_resources')
|
2018-06-19 13:22:30 +03:00
|
|
|
->values([
|
|
|
|
'backend_id' => $query->createNamedParameter('backend3'),
|
|
|
|
'resource_id' => $query->createNamedParameter('res6'),
|
|
|
|
'email' => $query->createNamedParameter('res6@foo.bar'),
|
|
|
|
'displayname' => $query->createNamedParameter('Pointer'),
|
|
|
|
'group_restrictions' => $query->createNamedParameter('["foo", "bar"]'),
|
|
|
|
])
|
|
|
|
->execute();
|
2019-08-01 15:03:34 +03:00
|
|
|
$id6 = $query->getLastInsertId();
|
|
|
|
|
|
|
|
$query->insert('calendar_resources_md')
|
|
|
|
->values([
|
|
|
|
'resource_id' => $query->createNamedParameter($id3),
|
|
|
|
'key' => $query->createNamedParameter('meta1'),
|
|
|
|
'value' => $query->createNamedParameter('value1')
|
|
|
|
])
|
|
|
|
->execute();
|
|
|
|
$query->insert('calendar_resources_md')
|
|
|
|
->values([
|
|
|
|
'resource_id' => $query->createNamedParameter($id3),
|
|
|
|
'key' => $query->createNamedParameter('meta2'),
|
|
|
|
'value' => $query->createNamedParameter('value2')
|
|
|
|
])
|
|
|
|
->execute();
|
|
|
|
$query->insert('calendar_resources_md')
|
|
|
|
->values([
|
|
|
|
'resource_id' => $query->createNamedParameter($id4),
|
|
|
|
'key' => $query->createNamedParameter('meta1'),
|
|
|
|
'value' => $query->createNamedParameter('value1')
|
|
|
|
])
|
|
|
|
->execute();
|
|
|
|
$query->insert('calendar_resources_md')
|
|
|
|
->values([
|
|
|
|
'resource_id' => $query->createNamedParameter($id4),
|
|
|
|
'key' => $query->createNamedParameter('meta3'),
|
|
|
|
'value' => $query->createNamedParameter('value3-old')
|
|
|
|
])
|
|
|
|
->execute();
|
|
|
|
$query->insert('calendar_resources_md')
|
|
|
|
->values([
|
|
|
|
'resource_id' => $query->createNamedParameter($id6),
|
|
|
|
'key' => $query->createNamedParameter('meta99'),
|
|
|
|
'value' => $query->createNamedParameter('value99')
|
|
|
|
])
|
|
|
|
->execute();
|
2018-06-19 13:22:30 +03:00
|
|
|
}
|
|
|
|
}
|