peterlck / hamcrest

Automatically exported from code.google.com/p/hamcrest
0 stars 0 forks source link

EqualTo matcher should check objects for equals() method #168

Closed GoogleCodeExporter closed 10 years ago

GoogleCodeExporter commented 10 years ago
Even though PHP doesn't have a natural equals() method concept, it makes more 
sense to compare two objects using one's equals() method rather than comparing 
that they have the same class.

    assertThat($foo, is($bar));

This should be equivalent to

    assertThat($foo->equals($bar), is(true));

because it's far more interesting than

    assertThat(get_class($foo), is(get_class($bar)));

A new sameClass() matcher or overriding anInstanceOf() to accept an object 
would make more sense for the last case.

Original issue reported on code.google.com by dharkn...@gmail.com on 16 Dec 2011 at 7:02