Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Equal to matcher no longer differentiates between different mocks of the same class #91

Description

@ezzatron

Because comparison used to descend into $_proxy inside each mock instance, and each proxy's state includes a unique integer label, this used to cause each mock instance to compare differently in cases like this:

$mockA = mock('ClassName')->mock();
$mockB = mock('ClassName')->mock();

$stub->with($mockA)->returns('a');
$stub->with($mockB)->returns('b');

But due to the changes in #82, these mock instances become equal, and it's breaking lots of existing tests.

There are a few options here:

  1. The tests could be updated to use some ===-style matcher:
$stub->with(sameInstance($mockA))->returns('a');
$stub->with(sameInstance($mockB))->returns('b');
  1. The proxy state, or part of it, could be re-added for comparison.
  2. Mock instances could be compared with ===, in contrast with every other object type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions