
## Review A dedicated reviewer checked the rule description successfully for: - [ ] logical errors and incorrect information - [ ] information gaps and missing content - [ ] text style and tone - [ ] PR summary and labels follow [the guidelines](https://github.com/SonarSource/rspec/#to-modify-an-existing-rule)
47 lines
921 B
Plaintext
47 lines
921 B
Plaintext
== Why is this an issue?
|
|
|
|
Testing equality or nullness with PHPUnit's ``++assertTrue()++`` or ``++assertFalse()++`` should be simplified to the corresponding dedicated assertion.
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,php]
|
|
----
|
|
assertTrue($a === $b);
|
|
assertTrue($a == $b);
|
|
assertTrue($a === null);
|
|
assertTrue($a !== null);
|
|
assertTrue($a !== $b);
|
|
assertTrue($a != $b);
|
|
assertFalse($a === $b);
|
|
assertFalse($a == $b);
|
|
assertTrue($a == true);
|
|
assertTrue($a == false);
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,php]
|
|
----
|
|
assertEquals($a, $b);
|
|
assertSame($a, $b);
|
|
assertNull($a);
|
|
assertNotNull($a);
|
|
assertNotEquals($a, $b);
|
|
assertNotSame($a, $b);
|
|
assertNotEquals($a, $b);
|
|
assertNotSame($a, $b);
|
|
assertTrue($a);
|
|
assertFalse($a);
|
|
----
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::../message.adoc[]
|
|
|
|
include::../highlighting.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|