CodeExplorer getCollectedData example
public function reset(): void
{ $this->data =
[ 'calls' =>
$this->
cloneVar([]),
'violations_count' => 0,
];
} public function lateCollect(): void
{ $collected =
$this->validator->
getCollectedData();
$this->data
['calls'
] =
$this->
cloneVar($collected);
$this->data
['violations_count'
] =
array_reduce($collected,
fn ($previous,
$item) =>
$previous + \
count($item['violations'
]), 0
);
} public function getCalls(): Data
{ return $this->data
['calls'
];
} public function getViolationsCount(): int
{ public function reset(): void
{ $this->data =
[ 'calls' =>
$this->
cloneVar([]),
'violations_count' => 0,
];
} public function lateCollect(): void
{ $collected =
$this->validator->
getCollectedData();
$this->data
['calls'
] =
$this->
cloneVar($collected);
$this->data
['violations_count'
] =
array_reduce($collected,
fn ($previous,
$item) =>
$previous + \
count($item['violations'
]), 0
);
} public function getCalls(): Data
{ return $this->data
['calls'
];
} public function getViolationsCount(): int
{ $originalValidator->
expects($this->
exactly(2
))->
method('validate'
)->
willReturn($violations);
$validator =
new TraceableValidator($originalValidator);
$object =
new \
stdClass();
$constraints =
[$this->
createMock(Constraint::
class)];
$groups =
['Default', 'Create'
];
$validator->
validate($object,
$constraints,
$groups);
$line = __LINE__ - 1;
$collectedData =
$validator->
getCollectedData();
$this->
assertCount(1,
$collectedData);
$callData =
$collectedData[0
];
$this->
assertSame(iterator_to_array($violations),
$callData['violations'
]);
$this->
assertSame([ 'value' =>
$object,
'constraints' =>
$constraints,
'groups' =>
$groups,
],