From 637cafcf35422fbf1280144ac68c71a3284be74f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 5 Sep 2023 09:18:25 +0200 Subject: [PATCH] Fix ContactsManagerTest adressbook mocks having a null key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/lib/ContactsManagerTest.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/lib/ContactsManagerTest.php b/tests/lib/ContactsManagerTest.php index d15cd74bef8c2..63491214eb70c 100644 --- a/tests/lib/ContactsManagerTest.php +++ b/tests/lib/ContactsManagerTest.php @@ -109,6 +109,9 @@ public function testDeleteHavePermission() { ->method('delete') ->willReturn('returnMe'); + $addressbook->expects($this->any()) + ->method('getKey') + ->willReturn('addressbookKey'); $this->cm->registerAddressBook($addressbook); $result = $this->cm->delete(1, $addressbook->getKey()); @@ -128,6 +131,10 @@ public function testDeleteNoPermission() { $addressbook->expects($this->never()) ->method('delete'); + $addressbook->expects($this->any()) + ->method('getKey') + ->willReturn('addressbookKey'); + $this->cm->registerAddressBook($addressbook); $result = $this->cm->delete(1, $addressbook->getKey()); $this->assertEquals($result, null); @@ -142,6 +149,10 @@ public function testDeleteNoAddressbook() { $addressbook->expects($this->never()) ->method('delete'); + $addressbook->expects($this->any()) + ->method('getKey') + ->willReturn('addressbookKey'); + $this->cm->registerAddressBook($addressbook); $result = $this->cm->delete(1, 'noaddressbook'); $this->assertEquals($result, null); @@ -161,6 +172,10 @@ public function testCreateOrUpdateHavePermission() { ->method('createOrUpdate') ->willReturn('returnMe'); + $addressbook->expects($this->any()) + ->method('getKey') + ->willReturn('addressbookKey'); + $this->cm->registerAddressBook($addressbook); $result = $this->cm->createOrUpdate([], $addressbook->getKey()); $this->assertEquals($result, 'returnMe'); @@ -179,6 +194,10 @@ public function testCreateOrUpdateNoPermission() { $addressbook->expects($this->never()) ->method('createOrUpdate'); + $addressbook->expects($this->any()) + ->method('getKey') + ->willReturn('addressbookKey'); + $this->cm->registerAddressBook($addressbook); $result = $this->cm->createOrUpdate([], $addressbook->getKey()); $this->assertEquals($result, null); @@ -193,6 +212,10 @@ public function testCreateOrUpdateNOAdressbook() { $addressbook->expects($this->never()) ->method('createOrUpdate'); + $addressbook->expects($this->any()) + ->method('getKey') + ->willReturn('addressbookKey'); + $this->cm->registerAddressBook($addressbook); $result = $this->cm->createOrUpdate([], 'noaddressbook'); $this->assertEquals($result, null); @@ -209,6 +232,10 @@ public function testIsEnabledIfSo() { ->disableOriginalConstructor() ->getMock(); + $addressbook->expects($this->any()) + ->method('getKey') + ->willReturn('addressbookKey'); + $this->cm->registerAddressBook($addressbook); $result = $this->cm->isEnabled(); $this->assertTrue($result);