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

For example, I want to check if a was either 1 or 3. I thought using this would work.

$this->assertThat(
    $this->assertContains('1',$array),
    $this->logicalOr(
        $this->assertContains('3',$array)
));
1
  • I thought assert accepted a boolean. If so Or those bitches together. Commented Aug 17, 2017 at 22:25

1 Answer 1

2

Pass your assertions as arguments into logicalOr

$this->assertThat($array, $this->logicalOr(
    $this->assertContains('3',$array),
    $this->assertContains('1',$array)
));
Sign up to request clarification or add additional context in comments.

3 Comments

I would get "Failed asserting that an array contains '1'" if '3' was in the array and vice-versa
@iii what happens if you remove the $array argument from assertThat?
This error: "Failed asserting that '1' contains '3' "

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.