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

Array subset works with flat arrays; #2781

Closed
wants to merge 1 commit into from
Closed

Array subset works with flat arrays; #2781

wants to merge 1 commit into from

Conversation

askovron
Copy link

Add possibility to check flat arrays within assertArrayContains

Fixes #2069

return 0;
}
}
if ($other_value > $subset_value) return 1;

Choose a reason for hiding this comment

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

Inline control structures are not allowed

@sebastianbergmann
Copy link
Owner

Thank you for your contribution. I appreciate the time you invested in preparing this pull request. However, I have decided not to merge it because I do not understand the issue (see #2069 (comment)) you're trying to solve here.

@askovron
Copy link
Author

askovron commented Feb 2, 2018

@sebastianbergmann

(1) The issue was (and is) that the arraySubset assertion passes only when the subset is located in the very beginning of the array.

Array = ['a', 'b', 'c']
Valid subset = ['a', 'b']
Invalid subset = ['b', 'c']

(2) The second issue is that the subset must be in the same order in both suubset and the original array.

Array = ['a', 'b', 'c']
Valid subset = ['a', 'b']
Invalid subset = ['b', 'a']

FYI. During tests had been running on this branch there were some errors not related to this feature.

@BonBonSlick
Copy link

BonBonSlick commented Dec 7, 2018

I am faced issues with auto indexed arrays today, what was solution?

"phpunit/phpunit": "^7.1",

  $content  = \json_decode($response->getContent(), true);
  static::assertArraySubset(
    [
      [
        'email' => '[email protected]',

Fails sometimes, because array with email has different int index.
Nothing in docs about that and I dont see any more asserts for this case, no comments in this thread with solution assert axmaple.

https://phpunit.de/manual/6.5/en/appendixes.assertions.html#appendixes.assertions.assertArraySubset

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.

4 participants