【发布时间】:2019-04-13 07:28:29
【问题描述】:
我的项目中有一些 PHPUnit 测试,其中一些使用了@expectedException 功能,如下所示。
/**
* @expectedException League\OAuth2\Client\Provider\Exception\IdentityProviderException
**/
public function testExceptionThrownWhenErrorObjectReceived()
{
...
}
/**
* @expectedException League\OAuth2\Client\Provider\Exception\IdentityProviderException
**/
public function testExceptionThrownWhenOAuthErrorReceived()
{
...
}
/**
* @expectedException UnexpectedValueException
**/
public function testExceptionThrownWhenAskingForResourceOwner()
{
...
}
我在 travis 的帮助下在 PHP 5.6、7.0、7.1 和 7.2 下运行它们没有问题,但 HHVM 失败:
There were 3 errors:
1) Mrjoops\OAuth2\Client\Test\Provider\JiraTest::testExceptionThrownWhenErrorObjectReceived
Mrjoops\OAuth2\Client\Provider\Exception\JiraIdentityProviderException: Validation Failed
2) Mrjoops\OAuth2\Client\Test\Provider\JiraTest::testExceptionThrownWhenOAuthErrorReceived
Mrjoops\OAuth2\Client\Provider\Exception\JiraIdentityProviderException: error_collection
3) Mrjoops\OAuth2\Client\Test\Provider\JiraTest::testExceptionThrownWhenAskingForResourceOwner
UnexpectedValueException: Invalid response received from Authorization Server. Expected JSON.
我使用最新的 PHPUnit 5.7 版本(为了兼容 PHP 5.6)和最新的 HHVM 3.29.1。
Travis 在他们的网站上写道:
请注意,如果你想在 HHVM 上运行 PHPUnit,你必须 在你的 .travis.yml 中明确安装 5.7 版 HHVM 与 PHP7 的兼容性问题
所以我想我没事。
我知道有一个已知问题 (https://github.com/sebastianbergmann/phpunit/issues/1640) 在 PHPUnit 中未解决并已关闭,并且在 HHVM (https://github.com/hhvm/user-documentation/blob/master/guides/hhvm/06-inconsistencies/03-classes-and-objects.md) 中记录了不一致,但我不清楚是否存在解决方法。
这里有详细信息:
- 测试文件:https://github.com/mrjoops/oauth2-jira/blob/develop/test/src/Provider/JiraTest.php
- 特拉维斯构建:https://travis-ci.org/mrjoops/oauth2-jira/jobs/452936060
提前感谢您的帮助。
【问题讨论】: