@GoodFirstBugs bot is back!

A couple of years ago, I created a Twitter bot that tweets out WordPress core trac tickets marked as GoodFirstBugs to help new contributors find a good starting place. It got a fantastic response from the community and even got an article on WP Tavern!

It had been offline for a while due to some issues with the account. Once I got that sorted out, I rewrote the bot to address some issues it was having with retrieving the trac report and added some new functionality to also include the list of issues labeled with Good First Issue from the Gutenberg project.

I am very excited to bring the bot back and hopefully it’s helpful! If you’re interested in contributing, the code is available on Github.

Should we trust WordPress Core translations?

A while ago I was working on a patch to refresh the code for the default widgets that are included with WordPress Core. One of the changes made was to replace the i18n methods currently in-place with their counterparts that escape and translate the output. This is a pretty common practice as translation files can be a potential attack vector for hackers. WordPress.com VIP will usually request that this is added to any strings being translated and it is part of the 10up best practices. Continue reading “Should we trust WordPress Core translations?”

Setting up Unit Testing for WordPress Core

Recently I was running into issues with VVV running some units tests for AJAX. I was not able to remedy the issue so I decided to create a testing environment from the SVN repo directly.

I went to the page on the codex and while the information there was great, part of the instructions are to setup a different database for your tests but not how to get mysql setup and ready for anything to connect to it.

After a bit of digging around I found a simple approach for setting up a test suite for WordPress core unit tests. This setup does not account for viewing WordPress in a browser it was really only meant for unit testing but you could easily set that up as well if required.

Using homebrew, install mysql

brew install mysql

Once installed, start the server

mysql.server start

Once the server has started you can login using the default user (root) and password (blank)

mysql -u root -p

You may be prompted for a password  if so, just hit enter.

Now you can create the tables as needed. There are two commands here because we need a database for WordPress regular use and one for unit testing because the test suite will drop all of the tables in the database each time it’s run.

CREATE DATABASE wp-unit-tests;
CREATE DATABASE wp-normal;

That’s it! Now your databases are all setup to use.

Next, checkout the WordPress repo into your user folder and change to that directory

svn co http://develop.svn.wordpress.org/trunk/ wordpress-develop
$ cd wordpress-develop

Now edit the wp-config.php and wp-test-config.php adding in the appropriate database connection info for each.

I found that I needed to set the DB_HOST constant to 127.0.0.1 instead of localhost to have the connection work.

If everything is setup correctly, you can run the unit test suite from inside the root of the core repo.

phpunit

Once you’re done with your testing you stop the mysql server as it can cause conflicts with other tools that use their own mysql installations.

mysql.server stop

That’s it! Happy unit testing!