downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the Git repository for this website on git.php.net.

Source of: /manual/en/internals2.pdo.testing.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/internals2.pdo.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'internals2.pdo.testing.php',
   
1 => 'Testing',
  ),
 
'up' =>
  array (
   
0 => 'internals2.pdo.php',
   
1 => 'PDO Driver How-To',
  ),
 
'prev' =>
  array (
   
0 => 'internals2.pdo.building.php',
   
1 => 'Building',
  ),
 
'next' =>
  array (
   
0 => 'internals2.pdo.packaging.php',
   
1 => 'Packaging and distribution',
  ),
 
'alternatives' =>
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="internals2.pdo.testing" class="sect1">
 <h2 class="title">Testing</h2>
 <p class="para">
  PDO has a set of &quot;core&quot; tests that all drivers should pass before being
  released.  They&#039;re designed to run from the PHP source distribution, so
  running the tests for your driver requires moving things around a bit.
  The suggested procedure is to obtain the latest PHP 5.1 snapshot and
  perform the following step:
 </p>

 <div class="example-contents screen"><div class="cdata"><pre>
$ cp -r pdo_SKEL /path/to/php-5.1/ext
</pre></div></div>
 <p class="para">
  This will allow the test harness to run your tests.  The next thing you
  need to do is create a test that will redirect into the PDO common core tests.
  The convention is to name this file <var class="filename">common.phpt</var>; it
  should be placed in the tests subdirectory that was created by
  <strong class="command">ext_skel</strong> when you created your extension skeleton.
  The content of this file should look something like the following:
 </p>
 <div class="example-contents"><div class="phptestcode"><pre class="phptestcode">--TEST--
SKEL
--SKIPIF--
&lt;?php # vim:ft=php
if (!extension_loaded(&#039;pdo_SKEL&#039;)) print &#039;skip&#039;; ?&gt;
--REDIRECTTEST--
if (false !== getenv(&#039;PDO_SKEL_TEST_DSN&#039;)) {
# user set them from their shell
   $config[&#039;ENV&#039;][&#039;PDOTEST_DSN&#039;] = getenv(&#039;PDO_SKEL_TEST_DSN&#039;);
   $config[&#039;ENV&#039;][&#039;PDOTEST_USER&#039;] = getenv(&#039;PDO_SKEL_TEST_USER&#039;);
   $config[&#039;ENV&#039;][&#039;PDOTEST_PASS&#039;] = getenv(&#039;PDO_SKEL_TEST_PASS&#039;);
   if (false !== getenv(&#039;PDO_SKEL_TEST_ATTR&#039;)) {
      $config[&#039;ENV&#039;][&#039;PDOTEST_ATTR&#039;] = getenv(&#039;PDO_SKEL_TEST_ATTR&#039;);
   }
   return $config;
}
return array(
   &#039;ENV&#039; =&gt; array(
           &#039;PDOTEST_DSN&#039; =&gt; &#039;SKEL:dsn&#039;,
           &#039;PDOTEST_USER&#039; =&gt; &#039;username&#039;,
           &#039;PDOTEST_PASS&#039; =&gt; &#039;password&#039;
       ),
   &#039;TESTS&#039; =&gt; &#039;ext/pdo/tests&#039;
   );</pre>
</div></div>


 <p class="para">
  This will cause the common core tests to be run, passing the values of
  <em>PDOTEST_DSN</em>, <em>PDOTEST_USER</em> and
  <em>PDOTEST_PASS</em> to the PDO constructor as the
  <em><code class="parameter">dsn</code></em>, <em><code class="parameter">username</code></em> and
  <em><code class="parameter">password</code></em> parameters.  It will first check the environment, so
  that appropriate values can be passed in when the test harness is run,
  rather than hard-coding the database credentials into the test file.
 </p>

 <p class="para">
  The test harness can be invoked as follows:
 </p>

 <div class="example-contents screen"><div class="cdata"><pre>
$ cd /path/to/php-5.1
$ make TESTS=ext/pdo_SKEL/tests PDO_SKEL_TEST_DSN=&quot;skel:dsn&quot; \
 PDO_SKEL_TEST_USER=user PDO_SKEL_TEST_PASS=pass test
 </pre></div></div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites