Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix ContactsManagerTest adressbook mocks having a null key
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Sep 5, 2023
commit 637cafcf35422fbf1280144ac68c71a3284be74f
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