diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-09-16 16:17:25 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-09-17 14:28:31 +0200 |
commit | 82ccb04182c0e7035030e2435a812b59407ffc37 (patch) | |
tree | d85564f272a05aac0fc921582cb8d49193e8c476 | |
parent | ebbd40385a2a1d722b5809174c5e80b756fdd040 (diff) | |
download | nextcloud-server-82ccb04182c0e7035030e2435a812b59407ffc37.tar.gz nextcloud-server-82ccb04182c0e7035030e2435a812b59407ffc37.zip |
adding unit test to truncate the table
-rw-r--r-- | apps/user_ldap/lib/helper.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/tests/helper.php | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php index bce28230fea..ecda49f73fc 100644 --- a/apps/user_ldap/lib/helper.php +++ b/apps/user_ldap/lib/helper.php @@ -172,7 +172,7 @@ class Helper { } /** - * extractsthe domain from a given URL + * extracts the domain from a given URL * @param string $url the URL * @return string|false domain as string on success, false otherwise */ diff --git a/apps/user_ldap/tests/helper.php b/apps/user_ldap/tests/helper.php new file mode 100644 index 00000000000..07c24d64499 --- /dev/null +++ b/apps/user_ldap/tests/helper.php @@ -0,0 +1,31 @@ +<?php +/** +* ownCloud +* +* @author Thomas Müller +* @copyright 2014 Thomas Müller deepdiver@owncloud.com +* +*/ + +namespace OCA\user_ldap\tests; + +use OCA\user_ldap\lib\Helper; + +class Test_Helper extends \PHPUnit_Framework_TestCase { + + public function testTableTruncate() { + + $statement = \OCP\DB::prepare('INSERT INTO `*PREFIX*ldap_user_mapping` (`ldap_dn`, `owncloud_name`, `directory_uuid`) VALUES (?, ?, ?)'); + $statement->execute(array('db01', 'oc1', '000-0000-0000')); + $statement->execute(array('db02', 'oc2', '000-0000-0001')); + + $statement = \OCP\DB::prepare('SELECT count(*) FROM `*PREFIX*ldap_user_mapping`'); + $result = $statement->execute(); + $this->assertEquals(2, $result->fetchOne()); + + Helper::clearMapping('user'); + + $result = $statement->execute(); + $this->assertEquals(0, $result->fetchOne()); + } +} |