]> source.dussan.org Git - nextcloud-server.git/commitdiff
adding unit test to truncate the table
authorThomas Müller <thomas.mueller@tmit.eu>
Tue, 16 Sep 2014 14:17:25 +0000 (16:17 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Tue, 16 Sep 2014 14:17:25 +0000 (16:17 +0200)
apps/user_ldap/lib/helper.php
apps/user_ldap/tests/helper.php [new file with mode: 0644]

index bce28230feaee8ef209c292c165dc2584a86563f..ecda49f73fcd0cd216ddbe6e9b60ca8f143ea4a8 100644 (file)
@@ -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 (file)
index 0000000..07c24d6
--- /dev/null
@@ -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());
+       }
+}