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

static void
validateExpectations(array $expected, int $argument, int $distance = 1)

No description

makeSelector()

Creates instance of ClassPropertySelector.

makeComparator()

Creates instance of IdentityComparator.

static ValuesInterface
makeExpectedValues(array $array)

Creates instance of ValuesInterface to be used as expected values.

Details

static RecursiveConstraintSpecializationTrait create(array $expected)

No description

Parameters

array $expected

Return Value

RecursiveConstraintSpecializationTrait

Exceptions

InvalidArgumentException

static protected void validateExpectations(array $expected, int $argument, int $distance = 1)

No description

Parameters

array $expected
int $argument
int $distance

Return Value

void

Exceptions

InvalidArgumentException

at line 64
static protected ValueSelectorInterface makeSelector()

Creates instance of ClassPropertySelector.

Return Value

ValueSelectorInterface

at line 55
static protected ComparatorInterface makeComparator()

Creates instance of IdentityComparator.

Return Value

ComparatorInterface

at line 73
static protected ValuesInterface makeExpectedValues(array $array)

Creates instance of ValuesInterface to be used as expected values.

Parameters

array $array

Return Value

ValuesInterface