ClassPropertiesEqualTo
final class ClassPropertiesEqualTo extends AbstractRecursiveConstraint
Constraint that accepts classes having properties equal 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 (equality) is
used for comparison.
Any key in $expected array ending with "()" is considered to be a
method that returns property value.
// ...
$matcher = ClassPropertiesEqualTo::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 EqualityComparator.
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 EqualityComparator.
at line 73
static protected ValuesInterface
makeExpectedValues(array $array)
Creates instance of ValuesInterface to be used as expected values.