1

The end of the first chapter of Professional WordPress Plugin Development by Wrox Press released February 2011 states:

To test a plugin during development make a test.php file and place it in the WordPress installation root directory.

However I've run a search in Aptana Studio for test.php in the WordPress source code and cannot find it. Where is the code which supposedly loads this file from WordPress's root directory and does it have to be named test.php or can it be also named something else?

4
  • 3
    Is this a physical book or can you link to it? I never heard of such a file before. Maybe there's context to that? If so: Please explain in an edit.
    – kaiser
    Commented Sep 16, 2014 at 10:13
  • It's a physical book. I've updated my post accordingly. Thanks for the feedback. Commented Sep 16, 2014 at 10:46
  • 1
    As you are saying, it states that test.php has to be created but what is the purpose of it? Why that is required when you can directly test your plugin from its main file.
    – Domain
    Commented Sep 16, 2014 at 17:42
  • 2
    Instead of doing this, perhaps PHPUnit or behat would be a better more structured way to test your code
    – Tom J Nowell
    Commented Sep 19, 2014 at 16:52

1 Answer 1

1

WordPress does not look for test.php; instead, you load it in your browser, like http://example.com/test.php.

4
  • Thank you for your reply. What I wanted to know is, where is the WordPress source code which will actually load this test.php file. I have searched the source code for test.php and found nothing. Commented Sep 19, 2014 at 12:59
  • I clarified my answer. Commented Sep 19, 2014 at 16:46
  • Still not sure what the advantage is of testing a plugin in this way and what would go inside such a file to test the plugin using the method described in the book. Commented Nov 27, 2014 at 16:44
  • 1
    Not for testing the complete plugin, but in the manner that @tom-j-nowell mentioned, as a unit test. For example, I test my plugin's update procedure this way first. Commented Nov 30, 2014 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.