Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is a 3rd "framework", which is by far easier to learn - even easier than <em>Simple</em>Test, it's called phpt.</p> <p>A primer can be found here: <a href="http://qa.php.net/write-test.php" rel="noreferrer">http://qa.php.net/write-test.php</a></p> <p><strong>Edit:</strong> Just saw your request for sample code.</p> <p>Let's assume you have the following function in a file called <em>lib.php</em>:</p> <pre><code>&lt;?php function foo($bar) { return $bar; } ?&gt; </code></pre> <p>Really simple and straight forward, the parameter you pass in, is returned. So let's look at a test for this function, we'll call the test file <em>foo.phpt</em>:</p> <pre><code>--TEST-- foo() function - A basic test to see if it works. :) --FILE-- &lt;?php include 'lib.php'; // might need to adjust path if not in the same dir $bar = 'Hello World'; var_dump(foo($bar)); ?&gt; --EXPECT-- string(11) "Hello World" </code></pre> <p>In a nutshell, we provide the parameter <code>$bar</code> with value <code>"Hello World"</code> and we <code>var_dump()</code> the response of the function call to <code>foo()</code>.</p> <p>To run this test, use: <code>pear run-test path/to/foo.phpt</code></p> <p>This requires <a href="http://pear.php.net/manual/en/installation.php" rel="noreferrer">a working install of PEAR</a> on your system, which is pretty common in most circumstances. If you need to install it, I recommend to install the latest version available. In case you need help to set it up, feel free to ask (but provide OS, etc.).</p>
    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