Skip to content

assertSame ignoring key order #6088

@Seldaek

Description

@Seldaek

Key order when we're talking about associative arrays is quite often irrelevant, especially when checking stuff that will end up being json serialized where dictionaries do not guarantee the key order.

Right now I'm stuck between using assertEqualsCanonicalizing and risking datatype errors, e.g.:

        $this->assertEqualsCanonicalizing(['foo' => 1], ['foo' => '1']); // true

Or use assertSame but then key order tends to make tests extra brittle. Having an option for assertSame or a new assertDictionarySame or something would be great.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature/assertionIssues related to assertions and expectationstype/enhancementA new idea that should be implemented

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions