How do I check or test a WordPress Auto Year Change Script?

Putting aside the legal issues, and focusing on a function for displaying the current year, the problem is actually pretty straightforward: The theme developer gave you the wrong code.

  • get_the_date( 'Y' ) gets the year of the publication date of the current post. This is not what you asked for.
  • date( 'Y' ) is a native PHP function that gets the current date and time on on the server. This is what they were probably meant to give you.
  • wp_date( 'Y' ) is a newer function (WordPress 5.3) that will get the current date and time, accounting for your timezone setting in WordPress. This is the one you’d be better off using.

This really isn’t something you should need to test. There’s no good reason that date() or wp_date() shouldn’t work. If you need assurances, I suggest testing each of these with a different format, so that you can at least see that they reflect the current day. If you use 'r' instead of 'Y' you will see a date like this:

Thu, 12 Mar 2020 09:30:00 +0200

If that date is not correct 2 days in a row, then the function you’re using won’t give you the correct year.

Ultimately this isn’t something that should be your responsibility to test. You just need the right information, and you weren’t given it. Now that you have the right information, you can rely on the PHP and WordPress developers to have done the testing to make sure their functions give the right dates.