WordPress switch domains

First of all, go to phpMyAdmin, go to your database for test.site.com and edit siteurl and/or home in wp_options table. That’ll fix your test.site.com

Now, to migrate test.site.com to site.com, as you’ve difficulties doing it manually, I’d suggest a plugin like Duplicator or All-in-One WP Migration to migrate the site. It’s way easier that way.

To do the migration manually

1). In phpMyAdmin, your database of test.site.com to another database. Here’ how to do it.

2). Replace all URL instances of test.site.com with site.com. Run the following query in your new copied DB

UPDATE wp_options SET option_value = replace(option_value, 'http://test.example.com', 'http://example.com') WHERE option_name="home" OR option_name="siteurl";
UPDATE wp_posts SET guid = replace(guid, 'http://test.example.com','http://example.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://test.example.com', 'http://example.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://test.example.com','http://example.com');

3). Now, move all files from public_html/test to public_html/site.

4). Lastly, change database details to the new copied database in wp-config.php