Merge branch '2013.10' into 2014.11
[tine20] / tests / tine20 / Tinebase / User / LdapTest.php
index 206745e..f7cd080 100644 (file)
@@ -70,7 +70,7 @@ class Tinebase_User_LdapTest extends TestCase
      */
     public function testGetUsers()
     {
-        $user = $this->testAddUser();
+        $this->testAddUser();
         
         $users = $this->_backend->getUsers('phpunit', 'accountStatus');
         
@@ -119,6 +119,7 @@ class Tinebase_User_LdapTest extends TestCase
         $groupsBeforeUpdate = $groupsBackend->getGroupMembershipsFromSyncBackend($user);
         
         $user->accountLoginName = 'tine20phpunituser-updated';
+        $this->_usernamesToDelete[] = $user->accountLoginName;
         $testUser = $this->_backend->updateUser($user);
         $groupsAfterUpdate = $groupsBackend->getGroupMembershipsFromSyncBackend($testUser);
         
@@ -217,7 +218,7 @@ class Tinebase_User_LdapTest extends TestCase
         
         $this->setExpectedException('Tinebase_Exception_NotFound');
         
-        $testUser = $this->_backend->getUserById($user, 'Tinebase_Model_FullUser');
+        $this->_backend->getUserById($user, 'Tinebase_Model_FullUser');
     }
     
     /**
@@ -351,4 +352,30 @@ class Tinebase_User_LdapTest extends TestCase
             $this->assertContains('Addressbook_Model_Contact record with id = ' . $sqlUser->contact_id, $tenf->getMessage());
         }
     }
+
+    /**
+     * test user status sync tine <-> ldap
+     *
+     * @see 0011554: improve ldap account status handling
+     */
+    public function testSyncUserStatus()
+    {
+        $user = $this->testAddUser();
+
+        // set user status in tine (disabled, expired, enabled)
+        $statusToTest = array(
+            Tinebase_Model_User::ACCOUNT_STATUS_EXPIRED,
+            Tinebase_Model_User::ACCOUNT_STATUS_DISABLED,
+            Tinebase_Model_User::ACCOUNT_STATUS_EXPIRED,
+            Tinebase_Model_User::ACCOUNT_STATUS_ENABLED,
+        );
+
+        foreach($statusToTest as $status) {
+            Tinebase_User::getInstance()->setStatus($user, $status);
+
+            // sync user -> user status should be the same
+            $syncedUser = Tinebase_User::syncUser($user, array('syncAccountStatus' => true));
+            $this->assertEquals($status, $syncedUser->accountStatus, print_r($syncedUser->toArray(), true));
+        }
+    }
 }