/** * Validate that the "migrate_all_users" method correctly deletes legacy * @uses $CFG, $DB * numeric user directories */ public function test_migrate_all_users_handles_deleted_users() { $this->resetAfterTest(true); $this->setup_test_data_xml(); global $CFG, $DB; $repo = repository_factory::factory('elisfiles'); // Our test username $username = '******'; // Set up the user in Alfresco $elisfiles = new ELIS_files(); $elisfiles->migrate_user($username); // Validate that the user exists and that their home directory was set up // (for sanity reasons only) $userexists = elis_files_request('/api/people/'.$username); $this->assertNotEquals(false, $userexists); $initialuserhome = elis_files_get_home_directory($username); $this->assertNotEquals(false, $initialuserhome); // Change the node name to the "old" style $test = elis_files_node_rename($initialuserhome, '100'); // Run the migration method $usr = new stdClass(); $usr->id = 100; $usr->deleted = 1; $DB->update_record('user', $usr); $elisfiles->migrate_all_users(); // Validate cleanup for the legacy folder $legacyuuid = false; $dir = elis_files_read_dir($elisfiles->uhomesuid, true); foreach ($dir->folders as $folder) { if ($folder->title == '100') { $legacyuuid = $folder->uuid; } } // Clean up the non-legacy data before final validation $elisfiles->delete_user($username); $this->assertEquals(false, $legacyuuid); }