I'm using PHPUnit with Mockery, the latter i installed via composer:
"require-dev": {
"mockery/mockery": "0.9.*"
},
Now, consider the following test case
<?php
use Mockery as m;
class FooTest extends PHPUnit_Framework_TestCase {
function testFoo() {
m::mock('DateTime');
}
}
phpunit
run fine. Now consider the following:
use Mockery as m;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class FooTest extends PHPUnit_Framework_TestCase {
function testFoo() {
m::mock('DateTime');
}
}
In this case i get a Class 'Mockery' not found
exception.
Mockery
is not found - actually, nothing in the /vendor
directory is found, as if the composer autoloading is totally messed up. I've ran both composer update
and 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>
I'm using PHPUnit 3.7.10 and i run tests with command line phpunit
without any args.
How can i fix this?
升级到PHPUnit 4.x为我解决了此问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.