The right way to do this is to flip options on and off. (The wrong way is to add code to the application to have a special “bypass” password that always succeeds.)
The problem is, as with WordPress unit testing, that it’s hard to get at WordPress’ environment to manipulate it.
WP unit testing does exactly that, but I didn’t want to mess up the global environment just to get a few functions. Besides, I didn’t know how to do it correctly. WP is a big application.
So I came up with this little library that has a get_option() and set_option() to manipulate options. I made an error and called it “set” instead of “update”.
The best part is, it is completely namespaced and doesn’t create any globals. I’m using “WP” but you can change that. Look at the comments to see how to use it.
No code, just look at the attachment.