Skip to content

Comments

Fix (create mutations for uncovered classes): adjust regex to ignore classnames which are prefixed with a classname to create mutations for#22

Open
CaptainRedbeard24 wants to merge 1 commit intopestphp:4.xfrom
CaptainRedbeard24:fix/class-to-mutate-detection
Open

Fix (create mutations for uncovered classes): adjust regex to ignore classnames which are prefixed with a classname to create mutations for#22
CaptainRedbeard24 wants to merge 1 commit intopestphp:4.xfrom
CaptainRedbeard24:fix/class-to-mutate-detection

Conversation

@CaptainRedbeard24
Copy link

Given following classes:

final class User implements UserInterface
{
    ...
}
final class UserCollection implements CollectionInterface
{
    ...
}

and a testfile:

covers(User::Class);
...

Currently the plugin would create mutations for both classes, even though the UserCollection class does not have any tests. This is due to the Regex in \Pest\Mutate\Support\MutationGenerator::doesNotContainClassToMutate /(?:class|trait)\\s+$class.*/. The $class.* will match everything that starts with the name of the target class.

This PR adds a word boundary after $class to prevent that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant