2

我有一个 phpunit.xml,它定义了要测试的测试以及引导文件的位置。我还想在我的 phpunit.xml 中定义可以在引导期间访问的参数。

这是我的 phpunit.xml:

<phpunit bootstrap="./bootstrap.php" colors="true" bootstrapArg="abcdefgh">
    <testsuite name="TestSuite">

        <file>./Test1.php</file>
        <file>./Test2.php</file>

</testsuite></phpunit>

我想在我的 bootstrap.php 中访问“bootstrapArg”的值。这可能吗?

谢谢

4

1 回答 1

5

配置可以包含遵循手册中描述<php>的规则的部分:

<php>
  <includePath>.</includePath>
  <ini name="foo" value="bar"/>
  <const name="foo" value="bar"/>
  <var name="foo" value="bar"/>
  <env name="foo" value="bar"/>
  <post name="foo" value="bar"/>
  <get name="foo" value="bar"/>
  <cookie name="foo" value="bar"/>
  <server name="foo" value="bar"/>
  <files name="foo" value="bar"/>
  <request name="foo" value="bar"/>
</php>

什么将导致以下引导代码:

ini_set('foo', 'bar');
define('foo', 'bar');
$GLOBALS['foo'] = 'bar';
$_ENV['foo'] = 'bar';
$_POST['foo'] = 'bar';
$_GET['foo'] = 'bar';
$_COOKIE['foo'] = 'bar';
$_SERVER['foo'] = 'bar';
$_FILES['foo'] = 'bar';
$_REQUEST['foo'] = 'bar';

您可以在引导过程中访问这些变量。

于 2013-09-13T09:26:37.833 回答