Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 30, 2018. It is now read-only.

Conversation

@babesflorin
Copy link
Contributor

@babesflorin babesflorin commented Aug 19, 2017

I've added the option 'path' for full path files to mutate. Files from path with be intersected with the files found by Symfony/Finder using config directory and 'file' option.
Ex:
Config:

{
    "timeout": 10,
    "source": {
        "directories": [
            "src"
        ],
        "excludes": [
            "vendor",
            "tests"
        ]
    },
    "logs": {
        "json": "humbug/humbuglog.json"
    }
}

Command:

humbug --file=Service.php \
--file=GetData.php \
--path=src/Data/Request/GetData.php \
--path=src/Data/Infrastructure/Persistence/DAL/GetData.php \
--path=src/Data/Response/GetData.php

Files found by Symfony/Finder:

src/Data/GetData.php
src/Data/Request/GetData.php
src/Data/Infrastructure/Persistence/DAL/GetData.php
src/Data/Service.php
src/Service.php

Running the command with the config above the mutated files will be:

src/Data/Request/GetData.php
src/Data/Infrastructure/Persistence/DAL/GetData.php

Florin Babes added 2 commits August 19, 2017 08:18
Copy link
Member

@theofidry theofidry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not gonna lie, I much prefer this approach to #263 :)

@humbug/core WDYT?


if (isset($paths)) {
$finder->filter(function (SplFileInfo $file) use ($paths) {
return \in_array($file, $paths);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the leading backslash can be removed

->addOption(
'path',
'p',
InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for the !, a . is enough :)

README.md Outdated
humbug --path=src/Data/NewClass.php --path=src/Driver/Driver.php
```

This in no way restricts the initial Humbug check on the overall test suite which
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a Note:

@theofidry
Copy link
Member

@holysleeper the changes LGTM but the tests are still failing

@babesflorin
Copy link
Contributor Author

@theofidry I saw the fails, I will fix them asap :). Thanks.

}

if (isset($paths)) {
if (!is_null($paths) && count($paths) > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the problematic value? I though it could only be an array or null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When --path option is not present, the default value is an empty array. Because of that "return in_array" is always false.

@theofidry theofidry merged commit 340d92e into humbug:master Aug 31, 2017
@theofidry
Copy link
Member

Thanks very much @holysleeper :)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants