【问题标题】:PhpUnit bootstrap argumentsPhpUnit 引导参数
【发布时间】:2013-09-13 09:09:14
【问题描述】:

我有一个 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”的值。这可能吗?

谢谢

【问题讨论】:

    标签: php phpunit


    【解决方案1】:

    配置可以包含遵循规则described in the manual&lt;php&gt; 部分:

    <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';
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-23
      • 2011-06-21
      • 2014-08-13
      • 2011-01-06
      • 2012-02-07
      • 2019-10-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多