Content restriction plugin 02

A first draft code pushed to GitHub.

A first tested and working version

I’ve developed a first code core for the content restriction plugin and pushed it to GitHub.
So far it does little more than activating and deactivating properly and I’ve TDDed just half of its core functionalities.
Those are restricting post queries and restricting template access: the former covered in the QueryRestrictor class and its first unit test case and the latter in the works.

Functional or unit?

While developing the QueryRestrictor class I’ve made ample usage of the Function Mocker package together with WP Browser and was able to cover its code with unit tests alone; it took me some time to decide whether I should use the WPLoader module that comes with WP Browser to power a “carefree” WordPress-powered functional test or stick to an environment insensible unit test leveraging the replacing powers function-mocker offers.
I’ve gone with the second option to keep my tests clear and on focus on the class at hand mocking its dependencies and as little WordPress set environment as I could (take a peek at the class tests to have an idea of what I’m talking about).


I will move to template redirection and then test helping classes where needed.