This is a classic use case for rsync. rsync will copy a directory tree from source to destination. It can also be asked to delete excess other files after the copy:
rsync -a -v --delete-after /var/www/html/test/ /var/www/html/test2
Note the trailing / on the source specification. If you omit this, it'll copy the source directory itself, which you won't want.
If you want it to be quiet, remove the -v. If the files are large and compressible, you might want to try adding -z to get it to do compression and decompression, but I doubt it'll gain much. The --delete-after option deletes just the excess files and folders from the destination, but not until after the other files have been copied.
A bonus of using rsync is that it will not bother copying files that are the same (i.e. already there and that actually match).