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 integer-indexed cases #428

Closed
wants to merge 1 commit into from
Closed

Fix integer-indexed cases #428

wants to merge 1 commit into from

Conversation

vojtech-dobes
Copy link
Contributor

  • bug fix
  • BC break? not sure to be honest
  • doc PR: shouldn't be needed

Description

Currently when PHP @dataProvider returns integer-indexed cases (simply array), in each run the first case is used.

Example

Given following test:

[$expected, $actual] = Tester\Environment::loadData();
Tester\Assert::same($expected, $actual);

With following data provider, all 3 cases will fail:

return [
    ['foo', 'bar'],
    ['foo', 'foo'],
    ['foo', 'foo'],
];

With following data provider, all 3 cases will succeed:

return [
    ['foo', 'foo'],
    ['foo', 'bar'],
    ['foo', 'bar'],
];

Summary

That's what this PR fixes :)

@milo
Copy link
Member

milo commented Jan 3, 2021

Uff, this is nasty bug. Thank you!

@milo
Copy link
Member

milo commented Jan 3, 2021

The is_int() condition is there because I thought, integer indexed items should never be filtered out. The bug is hidden in here

return reset($data);

I have to thing about it.

@milo milo closed this in eeea764 Jan 5, 2021
@vojtech-dobes
Copy link
Contributor Author

@milo Awesome, thanks!

@vojtech-dobes vojtech-dobes deleted the fix-integer-indexed-cases branch January 5, 2021 11:41
dg pushed a commit that referenced this pull request Jan 31, 2021
dg pushed a commit that referenced this pull request Jan 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants