internals2.pdo.testing.html
来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 90 行
HTML
90 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Testing</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="internals2.pdo.building.html">Building</a></div> <div class="next" style="text-align: right; float: right;"><a href="internals2.pdo.packaging.html">Packaging and distribution</a></div> <div class="up"><a href="internals2.pdo.html">PDO Driver How-To</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="internals2.pdo.testing" class="sect1"> <h2 class="title">Testing</h2> <p class="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: </p> <div class="example-contents"><pre><div class="cdata"><pre>$ cp -r pdo_SKEL /path/to/php-5.1/ext</pre></div></pre></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="cdata"><pre>--TEST--SKEL--SKIPIF--<?php # vim:ft=phpif (!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' );</pre></div></div> <p class="para"> This will cause the common core tests to be run, passing the values of <i>PDOTEST_DSN</i>, <i>PDOTEST_USER</i> and <i>PDOTEST_PASS</i> to the PDO constructor as the <i><tt class="parameter">dsn</tt></i>, <i><tt class="parameter">username</tt></i> and <i><tt class="parameter">password</tt></i> 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"><pre><div class="cdata"><pre>$ 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 </pre></div></pre></div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="internals2.pdo.building.html">Building</a></div> <div class="next" style="text-align: right; float: right;"><a href="internals2.pdo.packaging.html">Packaging and distribution</a></div> <div class="up"><a href="internals2.pdo.html">PDO Driver How-To</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?