Skip to content

How does one add a failing test case? #6563

@NotionCommotion

Description

@NotionCommotion

Question

I earlier asked another question here, but then that question morphed to something totally different so thought it best to create a new issue which is on topic. I am trying to gain a better understand how to perform https://github.com/rectorphp/rector/blob/main/docs/how_to_add_test_for_rector_rule.md, and have a few questions.

  1. Should Symfony be installed first (i.e. new symfony my_project)
  2. Should phpunit be installed first (i.e. composer require --dev phpunit/phpunit ^9)
  3. Is PhpStorm required? Note that I do not use it.
  4. Is there any other software (other than composer require rector/rector --dev of course) that needs to be installed?
  5. Must content from rector-src be used? Reason I ask is it has rules-tests/Privatization/Rector/Class_/FinalizeClassesWithoutChildrenRector/Fixture.
  6. When performing Step 3 Find the Rector Test Case, where are these directories and files located, and are they somehow automatically created by Rector (which they are not being done so for me) or do I manually add them? If I must manually add them, how do I know what content to include other than copying what is in rector-src?
  7. If PHPUnit fails and I've successfully added a test case, where do I find it so I can include with any bugs I might find?

I ended up copying rules-tests from rector-src to my project and then added add_final.php.inc to match the the script shown in step 4 Add Change or No-Change Test Fixture File. But when executing vendor/bin/phpunit rules-tests/Privatization/Rector/Class_/FinalizeClassesWithoutChildrenRector/FinalizeClassesWithoutChildrenRectorTest.php, got some errors that /src/constants.php and /preload.php were missing so just copied them from rector-src, and then that Class Symfony\Bridge\PhpUnit\SymfonyTestsListener does not exist and concluded I am obviously doing something wrong :(

Appreciate any help and apologize if I should already know how to do this.

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