|
|
|
|
@ -50,6 +50,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
private IUserManager&MockObject $userManager;
|
|
|
|
|
private IGroupManager&MockObject $groupManager;
|
|
|
|
|
private IEventDispatcher&MockObject $dispatcher;
|
|
|
|
|
private IConfig&MockObject $config;
|
|
|
|
|
private Backend $sharingBackend;
|
|
|
|
|
private IDBConnection $db;
|
|
|
|
|
private CardDavBackend $backend;
|
|
|
|
|
@ -96,6 +97,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
$this->userManager = $this->createMock(IUserManager::class);
|
|
|
|
|
$this->groupManager = $this->createMock(IGroupManager::class);
|
|
|
|
|
$this->config = $this->createMock(IConfig::class);
|
|
|
|
|
$this->principal = $this->getMockBuilder(Principal::class)
|
|
|
|
|
->setConstructorArgs([
|
|
|
|
|
$this->userManager,
|
|
|
|
|
@ -106,7 +108,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
$this->createMock(IAppManager::class),
|
|
|
|
|
$this->createMock(ProxyMapper::class),
|
|
|
|
|
$this->createMock(KnownUserService::class),
|
|
|
|
|
$this->createMock(IConfig::class),
|
|
|
|
|
$this->config,
|
|
|
|
|
$this->createMock(IFactory::class)
|
|
|
|
|
])
|
|
|
|
|
->onlyMethods(['getPrincipalByPath', 'getGroupMembership', 'findByUri'])
|
|
|
|
|
@ -135,6 +137,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
$this->userManager,
|
|
|
|
|
$this->dispatcher,
|
|
|
|
|
$this->sharingBackend,
|
|
|
|
|
$this->config,
|
|
|
|
|
);
|
|
|
|
|
// start every test with a empty cards_properties and cards table
|
|
|
|
|
$query = $this->db->getQueryBuilder();
|
|
|
|
|
@ -231,7 +234,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
public function testCardOperations(): void {
|
|
|
|
|
/** @var CardDavBackend&MockObject $backend */
|
|
|
|
|
$backend = $this->getMockBuilder(CardDavBackend::class)
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend])
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend,$this->config])
|
|
|
|
|
->onlyMethods(['updateProperties', 'purgeProperties'])
|
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
|
|
@ -291,7 +294,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
public function testMultiCard(): void {
|
|
|
|
|
$this->backend = $this->getMockBuilder(CardDavBackend::class)
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend])
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend,$this->config])
|
|
|
|
|
->onlyMethods(['updateProperties'])
|
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
|
|
@ -345,7 +348,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
public function testMultipleUIDOnDifferentAddressbooks(): void {
|
|
|
|
|
$this->backend = $this->getMockBuilder(CardDavBackend::class)
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend])
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend,$this->config])
|
|
|
|
|
->onlyMethods(['updateProperties'])
|
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
|
|
@ -368,7 +371,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
public function testMultipleUIDDenied(): void {
|
|
|
|
|
$this->backend = $this->getMockBuilder(CardDavBackend::class)
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend])
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend, $this->config])
|
|
|
|
|
->onlyMethods(['updateProperties'])
|
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
|
|
@ -390,7 +393,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
public function testNoValidUID(): void {
|
|
|
|
|
$this->backend = $this->getMockBuilder(CardDavBackend::class)
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend])
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend, $this->config])
|
|
|
|
|
->onlyMethods(['updateProperties'])
|
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
|
|
@ -408,7 +411,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
public function testDeleteWithoutCard(): void {
|
|
|
|
|
$this->backend = $this->getMockBuilder(CardDavBackend::class)
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend])
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend, $this->config])
|
|
|
|
|
->onlyMethods([
|
|
|
|
|
'getCardId',
|
|
|
|
|
'addChange',
|
|
|
|
|
@ -453,7 +456,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
|
|
|
|
|
public function testSyncSupport(): void {
|
|
|
|
|
$this->backend = $this->getMockBuilder(CardDavBackend::class)
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend])
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend, $this->config])
|
|
|
|
|
->onlyMethods(['updateProperties'])
|
|
|
|
|
->getMock();
|
|
|
|
|
|
|
|
|
|
@ -522,7 +525,7 @@ class CardDavBackendTest extends TestCase {
|
|
|
|
|
$cardId = 2;
|
|
|
|
|
|
|
|
|
|
$backend = $this->getMockBuilder(CardDavBackend::class)
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend])
|
|
|
|
|
->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->dispatcher, $this->sharingBackend, $this->config])
|
|
|
|
|
->onlyMethods(['getCardId'])->getMock();
|
|
|
|
|
|
|
|
|
|
$backend->expects($this->any())->method('getCardId')->willReturn($cardId);
|
|
|
|
|
|