ObjectPropertiesIdenticalTo
final class ObjectPropertiesIdenticalTo extends AbstractRecursiveConstraint
Constraint that accepts objects having properties identical to specified ones.
Compares only properties present in the array of expectations. A property is
defined as either an attribute value or a value returned by object's method
callable without arguments. The === operator (identity) is used for
comparison.
Any key in $expected array ending with "()" is considered to be a
method that returns property value.
// ...
$matcher = ObjectPropertiesIdenticalTo::create([
'getName()' => 'John', 'age' => 21
]);
self::assertThat(new class {
public static $age = 21;
public static getName(): string {
return 'John';
}
}, $matcher); Traits
Methods
No description
No description
Creates instance of ObjectPropertySelector.
Creates instance of IdentityComparator.
Creates instance of ValuesInterface to be used as expected values.
Details
in
RecursiveConstraintSpecializationTrait at line 28
static RecursiveConstraintSpecializationTrait
create(array $expected)
No description
in
ValidateExpectationsTrait at line 25
static protected void
validateExpectations(array $expected, int $argument, int $distance = 1)
No description
at line 64
static protected ValueSelectorInterface
makeSelector()
Creates instance of ObjectPropertySelector.
at line 55
static protected ComparatorInterface
makeComparator()
Creates instance of IdentityComparator.
at line 73
static protected ValuesInterface
makeExpectedValues(array $array)
Creates instance of ValuesInterface to be used as expected values.