如何使用Phpunit为数组中的键断言两个可能的值?

时间:2017-08-17 22:21:06

标签: php phpunit

$array = [a => '1',
 b => '2']

例如,我想检查a是1还是3。我认为使用它会起作用。

$this->assertThat(
    $this->assertContains('1',$array),
    $this->logicalOr(
        $this->assertContains('3',$array)
));

1 个答案:

答案 0 :(得分:1)

将您的断言作为参数传递给logicalOr

$this->assertThat($array, $this->logicalOr(
    $this->assertContains('3',$array),
    $this->assertContains('1',$array)
));