我正在使用PHPUnit和Mockery,后者是我通过composer安装的:
"require-dev": {
"mockery/mockery": "0.9.*"
},现在,考虑以下测试用例
<?php
use Mockery as m;
class FooTest extends PHPUnit_Framework_TestCase {
function testFoo() {
m::mock('DateTime');
}
}phpunit运行得很好。现在考虑以下内容:
use Mockery as m;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class FooTest extends PHPUnit_Framework_TestCase {
function testFoo() {
m::mock('DateTime');
}
}在这种情况下,我得到了一个Class 'Mockery' not found异常。
没有找到Mockery -实际上,在/vendor目录中什么也没有找到,就好像作曲家自动加载完全搞砸了一样。我运行过composer update和composer dump-autoload。
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>我使用的是PHPUnit 3.7.10,我使用命令行phpunit运行测试,没有任何参数。
我该如何解决这个问题呢?
发布于 2015-10-18 06:00:07
升级到PHPUnit 4.x修复了这个问题。
https://stackoverflow.com/questions/33187868
复制相似问题