gpt4 book ai didi

php - 我无法使用 phpunit : Cannot open file "autoload.php" 进行测试

转载 作者:可可西里 更新时间:2023-11-01 13:22:40 25 4
gpt4 key购买 nike


配置:

  • PHPUNIT:4.5.0
  • PHP:5.4.12
  • 服务器:Wamp
  • Composer :版本 1.0-dev 2015-02-17 21:55:44

Composer .json :

{
"require-dev": {
"phpunit/phpunit": "4.5.*"
}
}

自动加载.php :

<?php
date_default_timezone_set("Europe/Paris");

require __DIR__.'/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php';

use Symfony\Component\ClassLoader\UniversalClassLoader;

$loader = new UniversalClassLoader();

$loader->registerNamespaces(array(
'Hangman' => __DIR__.'/src',
'Symfony' => __DIR__.'/vendor',
));

$loader->register();

phpunit.xml :

<?xml version="1.0" encoding="UTF-8"?>

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="autoload.php"
>

<testsuites>
<testsuite name="hangman">
<directory>tests/Hangman/Tests</directory>
</testsuite>
</testsuites>

<filter>
<blacklist>
<directory>vendor</directory>
</blacklist>
</filter>
</phpunit>

问题:

我执行了:phpunit --bootstrap autoload.php 测试

我的错误:无法打开文件“autoload.php”

你能帮帮我吗?

最佳答案

我正在使用 PHPUnit 7 并在此基础上我在下面提到了经过测试并 100% 工作的解决方案

如果您是 Windows 用户,请在 cmd 中输入以下内容:"vendor/bin/phpunit"--bootstrap ./vendor/autoload.php ./tests/EmailTest

确保我在供应商和测试之前更新了 ./。

关于php - 我无法使用 phpunit : Cannot open file "autoload.php" 进行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28628969/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com