How to write a negative test in which I want to note that if count($jsonToArrayAll) not equal to 2, this is false.

 $this->assertFalse(assertNotEquals(2, count($jsonToArrayAll))); 
  • "this is a lie" - what does it mean? You should check if count($jsonToArrayAll) is equal to two or not and nothing else. Those. either $this->assertNotEquals(2, count($jsonToArrayAll)) , or $this->assertFalse(2 == count($jsonToArrayAll)); - BOPOH

1 answer 1

assertNotEquals() is a procedure, not a function — it returns nothing. Accordingly, assertFalse() will not work as expected.

That's right (any of these assertions):

 // проверяет, что всё условие не верно $this->assertFalse(2 == count($jsonToArrayAll)); // проверяет, что count($jsonToArrayAll) не равно 2 $this->assertNotEquals(2, count($jsonToArrayAll)); 
  • This is all clear, but I need to check from the negative side, in fact, count ($ jsonToArrayAll) is 2, with the words you can say that if count ($ jsonToArrayAll) is not 2, this is false. (that is, negative) - Narine Grigoryan
  • @NarineGrigoryan, well, it means the opposite is necessary: ​​either assertTrue , or assertEquals , you are trying to do something incomprehensible - BOPOH
  • @BOPOH $ this-> assertFalse (assertNotEquals (2, count ($ jsonToArrayAll))); what do you say about it? - Narine Grigoryan
  • @NarineGrigoryan, I wrote everything in the comment to the question: either one or the other. You should not have thoughts to do something else, because these two options fully cover all possible options - BOPOH