php-doc-en/internals/pdo/testing.xml
Dan Scott cf05ac7d25 Break PDO driver specification into one file per section.
Hopefully fix most whitespace issues.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@197512 c90b9560-bf6c-de11-be94-00142212c4b1
2005-10-03 22:02:16 +00:00

91 lines
2.9 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<sect1 id="internals.pdo.testing">
<title>Testing</title>
<para>
PDO has a set of "core" tests that all drivers should pass before being
released. They'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:
</para>
<screen><![CDATA[
$ cp -r pdo_SKEL /path/to/php-5.1/ext
]]></screen>
<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 <filename>common.phpt</filename>; it
should be placed in the tests subdirectory that was created by
<command>ext_skel</command> when you created your extension skeleton.
The content of this file should look something like the following:
</para>
<programlisting role="phptest"><![CDATA[
--TEST--
SKEL
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded('pdo_SKEL')) print 'skip'; ?>
--REDIRECTTEST--
if (false !== getenv('PDO_SKEL_TEST_DSN')) {
# user set them from their shell
$config['ENV']['PDOTEST_DSN'] = getenv('PDO_SKEL_TEST_DSN');
$config['ENV']['PDOTEST_USER'] = getenv('PDO_SKEL_TEST_USER');
$config['ENV']['PDOTEST_PASS'] = getenv('PDO_SKEL_TEST_PASS');
if (false !== getenv('PDO_SKEL_TEST_ATTR')) {
$config['ENV']['PDOTEST_ATTR'] = getenv('PDO_SKEL_TEST_ATTR');
}
return $config;
}
return array(
'ENV' => array(
'PDOTEST_DSN' => 'SKEL:dsn',
'PDOTEST_USER' => 'username',
'PDOTEST_PASS' => 'password'
),
'TESTS' => 'ext/pdo/tests'
);
]]></programlisting>
<para>
This will cause the common core tests to be run, passing the values of
<literal>PDOTEST_DSN</literal>, <literal>PDOTEST_USER</literal> and
<literal>PDOTEST_PASS</literal> to the PDO constructor as the
<parameter>dsn</parameter>, <parameter>username</parameter> and
<parameter>password</parameter> 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.
</para>
<para>
The test harness can be invoked as follows:
</para>
<screen><![CDATA[
$ cd /path/to/php-5.1
$ make TESTS=ext/pdo_SKEL/tests PDO_SKEL_TEST_DSN="skel:dsn" \
PDO_SKEL_TEST_USER=user PDO_SKEL_TEST_PASS=pass test
]]></screen>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->