Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when replacing placeholders in testdox using an associative array #3398

Closed
wants to merge 1 commit into from

Conversation

marcospassos
Copy link
Contributor

@marcospassos marcospassos commented Nov 10, 2018

At Croct we usually assign keys to data provider arguments to improve code readability:

private function dataProvider() : array
{
    return [
        '1 + 2 = 3' => [
            'augend' => 1,
            'addend' => 2,
            'result' => 3
        ]
    ];
}

It works fine in all cases except when the @testdox has placeholders. In this case you will get an error:

Undefined offset: 0

There is also a bug when omitting optional parameters in data providers:

private function dataProvider() : array
{
    return [
        [1]
    ];
}

/**
 * @testdox Message regarding $optional
 */
public function testFoo(int $value, bool $optional = true) : void
{
}

Warning:

Undefined offset: 1

This PR includes the fixes and tests for both scenarios.

@codecov
Copy link

codecov bot commented Nov 12, 2018

Codecov Report

Merging #3398 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3398      +/-   ##
============================================
+ Coverage     83.05%   83.06%   +<.01%     
- Complexity     3570     3572       +2     
============================================
  Files           143      143              
  Lines          9503     9505       +2     
============================================
+ Hits           7893     7895       +2     
  Misses         1610     1610
Impacted Files Coverage Δ Complexity Δ
src/Util/TestDox/NamePrettifier.php 98.8% <100%> (+0.02%) 38 <0> (+2) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdeb99a...22b79c7. Read the comment docs.

@epdenouden
Copy link
Contributor

@marcospassos Looks very useful :)

@sebastianbergmann
Copy link
Owner

Merged into 7.4, thanks.

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.

None yet

3 participants