summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-07-15 17:13:34 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-07-28 16:35:37 +0200
commit02a61c0b6a16e956a0a8fdf5889162e7c857c169 (patch)
tree85c850d200205133319d84e3ba0022fc33fa38f3 /tests
parent7cd1a48222b6e9c3b42df563b24e79f5a26a683f (diff)
downloadnextcloud-server-02a61c0b6a16e956a0a8fdf5889162e7c857c169.tar.gz
nextcloud-server-02a61c0b6a16e956a0a8fdf5889162e7c857c169.zip
ownCloud users are exported as address book
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/contacts/localadressbook.php95
1 files changed, 95 insertions, 0 deletions
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 @@
+<?php
+use OC\Contacts\LocalAddressBook;
+
+/**
+ * ownCloud
+ *
+ * @author Thomas Müller
+ * @copyright 2014 Thomas Müller thomas.mueller@tmit.eu
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+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) {
+ }
+}