How do I test to ensure that my wp-config file is protected?

The old method works for me, and any requests result in a 403 status response instead of execution of the php script. I’ve not checked your 2nd method, but if it works it will similarly respond with 403 denied/forbidden.

To test you simply have to insert the URL of your “wp-config.php” in the address bar of your browser e.g. http://example.com/wp-config.php . Depending on browser and/or sites custom 403 settings your browser will display “forbidden”, “access denied” etc.

Note you can also move wp-config.php one directory up from where WordPress installed it – and if this is then above Webroot/public_html it will no longer be “directly” accessible by hackers. More on this here Is moving wp-config outside the web root really beneficial?