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?

  • 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 Sep 16 '14 at 10:13
  • It's a physical book. I've updated my post accordingly. Thanks for the feedback. – John Sonderson Sep 16 '14 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. – WisdmLabs Sep 16 '14 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 Sep 19 '14 at 16:52
1

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

  • 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. – John Sonderson Sep 19 '14 at 12:59
  • I clarified my answer. – chrisdillon Sep 19 '14 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. – John Sonderson Nov 27 '14 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. – chrisdillon Nov 30 '14 at 17:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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