GitHub
07/25/2023, 6:11 PMatLeastAndMostLike
is my invention from #310, and I don't think it's useful. Instead, I replace it with arrayLike
(which is also my invention).
arrayLike
do what atLeastAndMostLike
do, which is checking both min
and max
, but it also:
• Allow any array as example value (so example value doesn't need to be a value appear multiple times)
• Allow min = 0 (in this case example value doesn't need to be empty array)
• Min can be null
• Max can be null
• Min and max can be both null (now it become $matcher->like()
)
• Min and max are not null (atLeastAndMostLike
above)
for example (UPDATED):
$fatherUuid = '67b06dc7-af63-41c7-b011-f9bbbe6f5d45';
$motherUuid = '73778b18-f6de-4193-9b5d-970b9a5aacb5';
$childUuid = '977e35b8-ded1-4380-b206-b64c0bc0a312';
$user = [
'id' => $matcher->uuid($childUuid),
'gender' => $matcher->regex('male', 'male|female|other'),
'firstName' => $macher->like('Bettye'),
'lastName' => $macher->like('Johnston'),
'birthday' => $matcher->date('yyyy-MM-dd', '2022-11-21'),
'relationships' => $matcher->like([
'spouses' => $matcher->arrayLike([$matcher->uuid('b21536d9-b0e4-4475-b9bc-b6d1d0716ba0')], 0),
'father' => $matcher->uuid($fatherUuid),
'mother' => $matcher->uuid($motherUuid),
'children' => $matcher->arrayLike([$matcher->uuid('fb08f967-830b-4c09-a9ea-716a37b8fd85')], 0),
]),
];
$father = [
'id' => $fatherUuid,
'gender' => 'male',
'firstName' => 'Deonte',
'lastName' => 'Zulauf',
'birthday' => '1970-11-21',
'relationships' => $matcher->like([
'spouses' => [$motherId],
'father' => null,
'mother' => null,
'children' => [$childUuid],
]),
];
$mother = [
'id' => $motherUuid,
'gender' => 'female',
'firstName' => 'Delpha',
'lastName' => 'Ryan',
'birthday' => '1986-11-21',
'relationships' => $matcher->like([
'spouses' => [$fatherUuid],
'father' => null,
'mother' => null,
'children' => [$childUuid],
]),
];
$users = $matcher->arrayLike([
$user,
$father,
$mother
], 1)
Link to specifications:
• https://github.com/pact-foundation/pact-specification/tree/version-4#supported-matching-rules
• https://github.com/pact-foundation/pact-specification/tree/version-3#supported-matchers
• https://github.com/pact-foundation/pact-specification/tree/version-2#supported-matchers
Code taken from pact-js
pact-foundation/pact-php
✅ All checks have passed
26/26 successful checksGitHub
07/28/2023, 5:21 PMGitHub
08/01/2023, 2:18 PM