Reply to comment

A Small Library to Change WordPress Options (useful for E2E WP Testing with Selenium)

I was messing with E2E testing of WordPress, and it was going okay, but I hit a wall when I needed to mess with one of the options, to turn of a CAPTCHA. You don't want to use deal with CAPTCHAs during a test, at least not every test. There may be some where you want to see the CAPTCHA.

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.

AttachmentSize
wp_mysql.php_.txt2.89 KB

Reply

The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options

8 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.