Skip to content

Rule to enforce class naming #214

Closed
Closed
@cs278

Description

@cs278

Generally speaking PHPUnit looks for tests in files named *Test.php, which conventionally means the classes should be named *Test. Additionally I believe it is recommended/required (I cannot find docs for this) that "tests" designed to be extended should be named *TestCase.

I propose adding rule to this extension which enforces that classes are named appropriately:

  • If a concrete class extends PHPUnit\Framework\TestCase and it should be named *Test - could also enforce final?
  • If an abstract class extends PHPUnit\Framework\TestCase it should be named *TestCase.

Ideally the rule would also enforce the file is named appropriately as well but that might be outside scope.

If this convention isn't followed and you don't explicitly tell PHPUnit your test files then tests are not run, potentially keeping the build passing because a number of tests are being silently ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions