Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In addition to the libraries/frameworks that <a href="https://stackoverflow.com/questions/530712/whats-the-state-of-tdd-and-or-bdd-in-php/530886#530886">Alan</a> has already mentioned, you can make use of mod_perl's Apache::Test, which I what I use as a harness. It allows me to very simply integrate tests into my release process. The harness uses <a href="http://en.wikipedia.org/wiki/Test_Anything_Protocol" rel="nofollow noreferrer">TAP</a> output (Test Anything Protocol) to determine whether or not the tests pass or fail, using libraries like <a href="http://search.cpan.org/dist/Test-Simple/lib/Test/Simple.pm" rel="nofollow noreferrer">Test::Simple</a> or Test::More (<a href="http://search.cpan.org/~mschwern/Test-Simple-0.86/lib/Test/More.pm" rel="nofollow noreferrer">Perl</a> and <a href="http://shiflett.org/code/test-more.php" rel="nofollow noreferrer">PHP</a>).</p> <p>Out of the box Apache::Test supports writing tests in both Perl and PHP. In my own projects, it took a little <a href="http://shiflett.org/blog/2004/dec/testing-php" rel="nofollow noreferrer">bit of trickery</a> and a lot of reading to really get it working, but an implementation of <a href="http://shiflett.org/code/test-more.php" rel="nofollow noreferrer">Test::More in PHP</a> is built-in to the harness. Running all tests written in both PHP and Perl is done through a single command and any failure along the way is captured Apache::Test, noting as best it can what went wrong.</p> <p>The awesome part about all this is that you can even utilize PHPUnit, or Simple-Test alongside the previous two testing frameworks. By running tests in each respective library, you can use the PHP implementation of Test::More (or even Perl by testing stdout) and spit back out TAP for your harness to interpret. </p> <p>Be sure to read the <a href="http://search.cpan.org/~phred/Apache-Test-1.30/lib/Apache/Test.pm" rel="nofollow noreferrer">Apache::Test</a> documentation and the <a href="http://perl.apache.org/docs/general/testing/testing.html" rel="nofollow noreferrer">mod_perl guide to running Apache::Test</a>. Additionally, I found the article <a href="http://www.digitalsandwich.com/archives/38-I-think-I-finally-understand-Apache-Test.html" rel="nofollow noreferrer">here</a> a great help. </p> <p>As a quick example, you could setup a test in Perl in very few lines of code that will run through all the pages on your site (that have links) and verify all result in '<code>200 OK</code>' responses and don't have any parsing errors:</p> <pre><code>#!perl use strict; use warnings; use Apache::Test qw(:withtestmore); use Apache::TestRequest; use Test::More; use Test::WWW::Mechanize; use WWW::CheckSite::Validator; use WWW::CheckSite::Spider; plan 'no_plan'; my $config = Apache::Test::config(); my $host = "http://". Apache::TestRequest::hostport($config) || ''; my $s = WWW::CheckSite::Spider-&gt;new( uri =&gt; $host, ua_class =&gt; 'Test::WWW::Mechanize', ); my $m = $s-&gt;current_agent; while (my $page = $s-&gt;get_page) { is($m-&gt;status(), "200", $m-&gt;uri() ." retrieved successfully."); $m-&gt;content_lacks("Parse Error", $m-&gt;uri() ." does not contain syntax errors."); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload