rspec/rules/S3360/php/rule.adoc
Fred Tingaud 51369b610e
Make sure that includes are always surrounded by empty lines (#2270)
When an include is not surrounded by empty lines, its content is inlined
on the same line as the adjacent content. That can lead to broken tags
and other display issues.
This PR fixes all such includes and introduces a validation step that
forbids introducing the same problem again.
2023-06-22 10:38:01 +02:00

66 lines
1.9 KiB
Plaintext

== Why is this an issue?
For better organization and clarity in test suites, test classes should end with `*Test.php`.
This naming convention helps to easily identify and distinguish test classes from other classes in the codebase.
It allows for automated test runners or frameworks to locate and execute the tests systematically.
The PHPUnit command-line test runner will look for `*Test.php` files.
In that case, test files without this pattern are ignored and not executed without warning.
=== What is the potential impact?
When tests are ignored or skipped, there can be several negative impacts on the development process and code quality.
Firstly, ignoring tests can lead to undetected bugs and vulnerabilities, as the skipped tests are not being executed and their associated functionality is not being thoroughly tested.
This increases the risk of releasing software with undiscovered issues.
Furthermore, skipped tests can result in a false sense of confidence, as developers might assume that the code is functioning correctly without proper validation.
This can lead to regression issues or unexpected behavior in the future when changes are made to the codebase.
== How to fix it
=== Code examples
==== Noncompliant code example
[source,php,diff-id=1,diff-type=noncompliant]
----
class TestClassX extends PHPUnit\Framework\TestCase { // Noncompliant
public void testDoTheThing() {
//...
----
==== Compliant solution
[source,php,diff-id=1,diff-type=compliant]
----
class ClassXTest extends PHPUnit\Framework\TestCase {
public void testDoTheThing() {
//...
----
== Resources
=== Documentation
* https://phpunit.de/documentation.html[PHPUnit documentation]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]