Skip to content

Commit

Permalink
Fix ContactsManagerTest adressbook mocks having a null key
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Sep 5, 2023
1 parent 5c78adb commit 637cafc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/lib/ContactsManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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');
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 637cafc

Please sign in to comment.