使用phpunit测试异常时出错

时间:2015-07-27 13:38:03

标签: php phpunit

我正在尝试测试此功能:

/**
 * @expectedException     InvalidArgumentException
 * @expectedExceptionMessage Invalid argument supplied for foreach()
 */
function testSetAdsData_dataIsNull()
{
    $dataArr = null;
    $fixture = new AdGroup();

    $fixture->setAdsData($dataArr);
}

但我在控制台中收到此错误:

有1个错误:

1) adGroupTest::testSetAdsData_dataIsNull
Invalid argument supplied for foreach()

/home/al/tests/adserver/src/classes/AdGroup.php:31
/home/al/tests/adserver/test/classes/AdGroupTest.php:65

FAILURES!
Tests: 15, Assertions: 23, Errors: 1.

@expectedExceptionMessage是不是应该让我免于得到这个错误?或者我错过了其他什么?

0 个答案:

没有答案