Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
'OCP\\Comments\\NotFoundException' => $baseDir . '/lib/public/Comments/NotFoundException.php',
'OCP\\Console\\ConsoleEvent' => $baseDir . '/lib/public/Console/ConsoleEvent.php',
'OCP\\Constants' => $baseDir . '/lib/public/Constants.php',
'OCP\\Contacts' => $baseDir . '/lib/public/Contacts.php',
'OCP\\Contacts\\ContactsMenu\\IAction' => $baseDir . '/lib/public/Contacts/ContactsMenu/IAction.php',
'OCP\\Contacts\\ContactsMenu\\IActionFactory' => $baseDir . '/lib/public/Contacts/ContactsMenu/IActionFactory.php',
'OCP\\Contacts\\ContactsMenu\\IContactsStore' => $baseDir . '/lib/public/Contacts/ContactsMenu/IContactsStore.php',
Expand Down
1 change: 0 additions & 1 deletion lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Comments\\NotFoundException' => __DIR__ . '/../../..' . '/lib/public/Comments/NotFoundException.php',
'OCP\\Console\\ConsoleEvent' => __DIR__ . '/../../..' . '/lib/public/Console/ConsoleEvent.php',
'OCP\\Constants' => __DIR__ . '/../../..' . '/lib/public/Constants.php',
'OCP\\Contacts' => __DIR__ . '/../../..' . '/lib/public/Contacts.php',
'OCP\\Contacts\\ContactsMenu\\IAction' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IAction.php',
'OCP\\Contacts\\ContactsMenu\\IActionFactory' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IActionFactory.php',
'OCP\\Contacts\\ContactsMenu\\IContactsStore' => __DIR__ . '/../../..' . '/lib/public/Contacts/ContactsMenu/IContactsStore.php',
Expand Down
185 changes: 0 additions & 185 deletions lib/public/Contacts.php

This file was deleted.

36 changes: 23 additions & 13 deletions tests/lib/PublicNamespace/ContactsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,24 @@

namespace Test\PublicNamespace;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be in Contacts/ManagerTest.php now?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


use OCP\IAddressBook;

class ContactsTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
\OCP\Contacts::clear();
\OC::$server->getContactsManager()->clear();
}

public function testDisabledIfEmpty() {
// pretty simple
$this->assertFalse(\OCP\Contacts::isEnabled());
$this->assertFalse(\OC::$server->getContactsManager()->isEnabled());
}

public function testEnabledAfterRegister() {
$cm = \OC::$server->getContactsManager();

// create mock for the addressbook
/** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $stub */
$stub = $this->getMockForAbstractClass("OCP\IAddressBook", array('getKey'));

// we expect getKey to be called twice:
Expand All @@ -43,23 +48,24 @@ public function testEnabledAfterRegister() {
->method('getKey');

// not enabled before register
$this->assertFalse(\OCP\Contacts::isEnabled());
$this->assertFalse($cm->isEnabled());

// register the address book
\OCP\Contacts::registerAddressBook($stub);
$cm->registerAddressBook($stub);

// contacts api shall be enabled
$this->assertTrue(\OCP\Contacts::isEnabled());
$this->assertTrue($cm->isEnabled());

// unregister the address book
\OCP\Contacts::unregisterAddressBook($stub);
$cm->unregisterAddressBook($stub);

// not enabled after register
$this->assertFalse(\OCP\Contacts::isEnabled());
$this->assertFalse($cm->isEnabled());
}

public function testAddressBookEnumeration() {
// create mock for the addressbook
/** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $stub */
$stub = $this->getMockForAbstractClass("OCP\IAddressBook", array('getKey', 'getDisplayName'));

// setup return for method calls
Expand All @@ -71,16 +77,19 @@ public function testAddressBookEnumeration() {
->will($this->returnValue('A very simple Addressbook'));

// register the address book
\OCP\Contacts::registerAddressBook($stub);
$all_books = \OCP\Contacts::getAddressBooks();
$cm = \OC::$server->getContactsManager();
$cm->registerAddressBook($stub);
$all_books = $cm->getAddressBooks();

$this->assertEquals(1, count($all_books));
$this->assertEquals('A very simple Addressbook', $all_books['SIMPLE_ADDRESS_BOOK']);
}

public function testSearchInAddressBook() {
// create mock for the addressbook
/** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $stub1 */
$stub1 = $this->getMockForAbstractClass("OCP\IAddressBook", array('getKey', 'getDisplayName', 'search'));
/** @var \PHPUnit_Framework_MockObject_MockObject|IAddressBook $stub2 */
$stub2 = $this->getMockForAbstractClass("OCP\IAddressBook", array('getKey', 'getDisplayName', 'search'));

$searchResult1 = array(
Expand All @@ -103,15 +112,16 @@ public function testSearchInAddressBook() {
$stub2->expects($this->any())->method('search')->will($this->returnValue($searchResult2));

// register the address books
\OCP\Contacts::registerAddressBook($stub1);
\OCP\Contacts::registerAddressBook($stub2);
$all_books = \OCP\Contacts::getAddressBooks();
$cm = \OC::$server->getContactsManager();
$cm->registerAddressBook($stub1);
$cm->registerAddressBook($stub2);
$all_books = $cm->getAddressBooks();

// assert the count - doesn't hurt
$this->assertEquals(2, count($all_books));

// perform the search
$result = \OCP\Contacts::search('x', array());
$result = $cm->search('x', array());

// we expect 4 hits
$this->assertEquals(4, count($result));
Expand Down
5 changes: 0 additions & 5 deletions tests/lib/PublicNamespace/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@


class UtilTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();
\OCP\Contacts::clear();
}

/**
* @dataProvider channelProvider
*
Expand Down