2014-07-15 15:13:34 +00:00
|
|
|
<?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/>.
|
|
|
|
*/
|
|
|
|
|
2014-11-10 22:30:38 +00:00
|
|
|
class Test_LocalAddressBook extends \Test\TestCase
|
2014-07-15 15:13:34 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public function testSearchFN() {
|
|
|
|
$stub = $this->getMockForAbstractClass('\OCP\IUserManager', array('searchDisplayName'));
|
|
|
|
|
2014-07-28 20:38:56 +00:00
|
|
|
$stub->expects($this->any())->method('searchDisplayName')->will($this->returnValue(array(
|
2014-07-15 15:13:34 +00:00
|
|
|
new SimpleUserForTesting('tom', 'Thomas'),
|
|
|
|
new SimpleUserForTesting('tomtom', 'Thomas T.'),
|
|
|
|
)));
|
|
|
|
|
|
|
|
$localAddressBook = new LocalAddressBook($stub);
|
|
|
|
|
|
|
|
$result = $localAddressBook->search('tom', array('FN'), array());
|
2014-07-28 20:38:56 +00:00
|
|
|
$this->assertEquals(2, count($result));
|
2014-07-15 15:13:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testSearchId() {
|
|
|
|
$stub = $this->getMockForAbstractClass('\OCP\IUserManager', array('searchDisplayName'));
|
|
|
|
|
2014-07-28 20:38:56 +00:00
|
|
|
$stub->expects($this->any())->method('search')->will($this->returnValue(array(
|
2014-07-15 15:13:34 +00:00
|
|
|
new SimpleUserForTesting('tom', 'Thomas'),
|
|
|
|
new SimpleUserForTesting('tomtom', 'Thomas T.'),
|
|
|
|
)));
|
|
|
|
|
|
|
|
$localAddressBook = new LocalAddressBook($stub);
|
|
|
|
|
|
|
|
$result = $localAddressBook->search('tom', array('id'), array());
|
2014-07-28 20:38:56 +00:00
|
|
|
$this->assertEquals(2, count($result));
|
2014-07-15 15:13:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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() {
|
|
|
|
}
|
|
|
|
|
2014-07-28 20:38:56 +00:00
|
|
|
public function setPassword($password, $recoveryPassword = null) {
|
2014-07-15 15:13:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getHome() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function canChangeAvatar() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function canChangePassword() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function canChangeDisplayName() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function isEnabled() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setEnabled($enabled) {
|
|
|
|
}
|
|
|
|
}
|