From 176ecbd31199370b68e310aa0dc361a4e25a04ea Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Tue, 15 Jul 2014 17:13:34 +0200 Subject: ownCloud users are exported as address book --- tests/lib/contacts/localadressbook.php | 95 ++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/lib/contacts/localadressbook.php (limited to 'tests/lib') diff --git a/tests/lib/contacts/localadressbook.php b/tests/lib/contacts/localadressbook.php new file mode 100644 index 00000000000..276863aeb6c --- /dev/null +++ b/tests/lib/contacts/localadressbook.php @@ -0,0 +1,95 @@ +. + */ + +class Test_LocalAddressBook extends PHPUnit_Framework_TestCase +{ + + public function testSearchFN() { + $stub = $this->getMockForAbstractClass('\OCP\IUserManager', array('searchDisplayName')); + + $stub->expects($this->any())->method('searchDisplayName')->will($this->return(array( + new SimpleUserForTesting('tom', 'Thomas'), + new SimpleUserForTesting('tomtom', 'Thomas T.'), + ))); + + $localAddressBook = new LocalAddressBook($stub); + + $result = $localAddressBook->search('tom', array('FN'), array()); + $this->assertEqual(2, count($result)); + } + + public function testSearchId() { + $stub = $this->getMockForAbstractClass('\OCP\IUserManager', array('searchDisplayName')); + + $stub->expects($this->any())->method('search')->will($this->return(array( + new SimpleUserForTesting('tom', 'Thomas'), + new SimpleUserForTesting('tomtom', 'Thomas T.'), + ))); + + $localAddressBook = new LocalAddressBook($stub); + + $result = $localAddressBook->search('tom', array('id'), array()); + $this->assertEqual(2, count($result)); + } +} + + +class SimpleUserForTesting implements \OCP\IUser { + + public function __construct($uid, $displayName) { + + $this->uid = $uid; + $this->displayName = $displayName; + } + + public function getUID() { + return $this->uid; + } + + public function getDisplayName() { + return $this->displayName; + } + + public function setDisplayName($displayName) { + } + + public function getLastLogin() { + } + + public function updateLastLoginTimestamp() { + } + + public function delete() { + } + + public function setPassword($password, $recoveryPassword) { + } + + public function getHome() { + } + + public function canChangeAvatar() { + } + + public function canChangePassword() { + } + + public function canChangeDisplayName() { + } + + public function isEnabled() { + } + + public function setEnabled($enabled) { + } +} -- cgit v1.2.3