ClassPropertiesIdenticalTo
final class ClassPropertiesIdenticalTo extends AbstractRecursiveConstraint
Constraint that accepts classes having properties identical to specified ones.
Compares only properties present in the array of expectations. A property is
defined as either a static attribute value or a value returned by class'
static 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 = ClassPropertiesIdenticalTo::create([
'getName()' => 'John', 'age' => 21
]);
self::assertThat(get_class(new class {
public static $age = 21;
public static getName(): string {
return 'John';
}
}), $matcher); Traits
Methods
No description
No description
Creates instance of ClassPropertySelector.
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 ClassPropertySelector.
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.