Skip to content

Commit

Permalink
test: update datasets to work with pest v3 (resolves #2352) (#2417)
Browse files Browse the repository at this point in the history
* Revert "test: fix deprecation errors (#2351)"

This reverts commit e04e0d5.

* test: update datasets to work with pest v3
  • Loading branch information
jobara authored Dec 4, 2024
1 parent b5e5841 commit a0861a4
Show file tree
Hide file tree
Showing 41 changed files with 1,157 additions and 1,157 deletions.
18 changes: 9 additions & 9 deletions tests/Datasets/AddOrganizationValidationErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
use App\Models\Organization;

dataset('addOrganizationValidationErrors', function () {
return array_map('array_values', [
'Organization id is missing' => [
return [
'Organization id is missing' => fn () => [
'state' => ['organization_id' => null],
'errors' => fn () => ['organization_id' => __('validation.required', ['attribute' => __('organization.singular_name')])],
'errors' => ['organization_id' => __('validation.required', ['attribute' => __('organization.singular_name')])],
],
'Organization id is invalid' => [
'Organization id is invalid' => fn () => [
'state' => ['organization_id' => 1000000],
'errors' => fn () => ['organization_id' => __('validation.exists', ['attribute' => __('organization.singular_name')])],
'errors' => ['organization_id' => __('validation.exists', ['attribute' => __('organization.singular_name')])],
],
'Organization is not a participant' => [
'state' => fn () => ['organization_id' => Organization::factory()->create([
'Organization is not a participant' => fn () => [
'state' => ['organization_id' => Organization::factory()->create([
'name' => 'not a participant org',
'roles' => [OrganizationRole::CommunityConnector->value],
])->id],
'errors' => fn () => ['organization_id' => __('The organization you have added does not participate in engagements.')],
'errors' => ['organization_id' => __('The organization you have added does not participate in engagements.')],
],
]);
];
});
2 changes: 1 addition & 1 deletion tests/Datasets/BrowseEngagementsFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
];
}

return array_map('array_values', $testCases);
return $testCases;
});
16 changes: 8 additions & 8 deletions tests/Datasets/DestroyIndividualRequestValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

dataset('destroyIndividualRequestValidationErrors', function () {
return array_map('array_values', [
'Current password is missing' => [
return [
'Current password is missing' => fn () => [
'state' => ['current_password' => null],
'errors' => fn () => ['current_password' => __('validation.required', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.required', ['attribute' => __('current password')])],
],
'Current password is not a string' => [
'Current password is not a string' => fn () => [
'state' => ['current_password' => false],
'errors' => fn () => ['current_password' => __('validation.string', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.string', ['attribute' => __('current password')])],
],
'Current password does not match' => [
'Current password does not match' => fn () => [
'state' => ['current_password' => 'fake_password'],
'errors' => fn () => ['current_password' => __('The provided password does not match your current password.')],
'errors' => ['current_password' => __('The provided password does not match your current password.')],
],
]);
];
});
16 changes: 8 additions & 8 deletions tests/Datasets/DestroyOrganizationRequestValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

dataset('destroyOrganizationRequestValidationErrors', function () {
return array_map('array_values', [
'Current password is missing' => [
return [
'Current password is missing' => fn () => [
'state' => ['current_password' => null],
'errors' => fn () => ['current_password' => __('validation.required', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.required', ['attribute' => __('current password')])],
],
'Current password is not a string' => [
'Current password is not a string' => fn () => [
'state' => ['current_password' => false],
'errors' => fn () => ['current_password' => __('validation.string', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.string', ['attribute' => __('current password')])],
],
'Current password does not match' => [
'Current password does not match' => fn () => [
'state' => ['current_password' => 'fake_password'],
'errors' => fn () => ['current_password' => __('validation.current_password', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.current_password', ['attribute' => __('current password')])],
],
]);
];
});
16 changes: 8 additions & 8 deletions tests/Datasets/DestroyProjectRequestValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

dataset('destroyProjectRequestValidationErrors', function () {
return array_map('array_values', [
'Current password is missing' => [
return [
'Current password is missing' => fn () => [
'state' => [],
'errors' => fn () => ['current_password' => __('validation.required', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.required', ['attribute' => __('current password')])],
],
'Current password is not a string' => [
'Current password is not a string' => fn () => [
'state' => ['current_password' => false],
'errors' => fn () => ['current_password' => __('validation.string', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.string', ['attribute' => __('current password')])],
],
'Current password is not valid' => [
'Current password is not valid' => fn () => [
'state' => ['current_password' => 'WrongPassword'],
'errors' => fn () => ['current_password' => __('The provided password does not match your current password.')],
'errors' => ['current_password' => __('The provided password does not match your current password.')],
],
]);
];
});
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

dataset('destroyRegulatedOrganizationRequestValidationErrors', function () {
return array_map('array_values', [
'Current password is missing' => [
return [
'Current password is missing' => fn () => [
'state' => ['current_password' => null],
'errors' => fn () => ['current_password' => __('validation.required', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.required', ['attribute' => __('current password')])],
],
'Current password is not a string' => [
'Current password is not a string' => fn () => [
'state' => ['current_password' => false],
'errors' => fn () => ['current_password' => __('validation.string', ['attribute' => __('current password')])],
'errors' => ['current_password' => __('validation.string', ['attribute' => __('current password')])],
],
'Current password does not match' => [
'Current password does not match' => fn () => [
'state' => ['current_password' => 'fake_password'],
'errors' => fn () => ['current_password' => __('The provided password does not match your current password.')],
'errors' => ['current_password' => __('The provided password does not match your current password.')],
],
]);
];
});
24 changes: 12 additions & 12 deletions tests/Datasets/InviteParticipantValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
<?php

dataset('inviteParticipantValidationErrors', function () {
return array_map('array_values', [
'Email is missing' => [
return [
'Email is missing' => fn () => [
'state' => ['email' => null],
'errors' => fn () => ['email' => __('You must enter an email address.')],
'errors' => ['email' => __('You must enter an email address.')],
],
'User already invited' => [
'User already invited' => fn () => [
'state' => ['email' => '[email protected]'],
'errors' => fn () => ['email' => __('This individual has already been invited to your engagement.')],
'errors' => ['email' => __('This individual has already been invited to your engagement.')],
],
'User already added to engagement' => [
'User already added to engagement' => fn () => [
'state' => ['email' => '[email protected]'],
'errors' => fn () => ['email' => __('The individual with the email address you provided is already participating in this engagement.')],
'errors' => ['email' => __('The individual with the email address you provided is already participating in this engagement.')],
],
'User not a consultation participant' => [
'User not a consultation participant' => fn () => [
'state' => ['email' => '[email protected]'],
'errors' => fn () => ['email' => __('The person with the email address you provided is not a consultation participant.')],
'errors' => ['email' => __('The person with the email address you provided is not a consultation participant.')],
],
'Email address not for an individual user' => [
'Email address not for an individual user' => fn () => [
'state' => ['email' => '[email protected]'],
'errors' => fn () => ['email' => __('The person with the email address you provided is not a consultation participant.')],
'errors' => ['email' => __('The person with the email address you provided is not a consultation participant.')],
],
]);
];
});
16 changes: 8 additions & 8 deletions tests/Datasets/SaveOrganizationRolesRequestValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

dataset('saveOrganizationRolesRequestValidationErrors', function () {
return array_map('array_values', [
'Roles is missing' => [
return [
'Roles is missing' => fn () => [
'state' => ['roles' => null],
'errors' => fn () => ['roles' => __('You must select a role for your organization.')],
'errors' => ['roles' => __('You must select a role for your organization.')],
],
'Roles is not an array' => [
'Roles is not an array' => fn () => [
'state' => ['roles' => false],
'errors' => fn () => ['roles' => __('validation.array', ['attribute' => __('roles')])],
'errors' => ['roles' => __('validation.array', ['attribute' => __('roles')])],
],
'Role is invalid' => [
'Role is invalid' => fn () => [
'state' => ['roles' => ['other']],
'errors' => fn () => ['roles.0' => __('validation.exists', ['attribute' => __('roles')])],
'errors' => ['roles.0' => __('validation.exists', ['attribute' => __('roles')])],
],
]);
];
});
12 changes: 6 additions & 6 deletions tests/Datasets/StoreAccessNeedsPermissionsValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

dataset('storeAccessNeedsPermissionsValidationErrors', function () {
return array_map('array_values', [
'Share access needs is missing' => [
return [
'Share access needs is missing' => fn () => [
'state' => [],
'errors' => fn () => ['share_access_needs' => __('validation.required', ['attribute' => __('share access needs')])],
'errors' => ['share_access_needs' => __('validation.required', ['attribute' => __('share access needs')])],
],
'Share access needs is not a boolean' => [
'Share access needs is not a boolean' => fn () => [
'state' => ['share_access_needs' => 123],
'errors' => fn () => ['share_access_needs' => __('validation.boolean', ['attribute' => __('share access needs')])],
'errors' => ['share_access_needs' => __('validation.boolean', ['attribute' => __('share access needs')])],
],
]);
];
});
12 changes: 6 additions & 6 deletions tests/Datasets/StoreEngagementFormatRequestValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

dataset('storeEngagementFormatRequestValidationErrors', function () {
return array_map('array_values', [
'Format is missing' => [
return [
'Format is missing' => fn () => [
'state' => ['format' => null],
'errors' => fn () => ['format' => __('validation.required', ['attribute' => __('engagement format')])],
'errors' => ['format' => __('validation.required', ['attribute' => __('engagement format')])],
],
'Format is invalid' => [
'Format is invalid' => fn () => [
'state' => ['format' => ['xyz']],
'errors' => fn () => ['format' => __('validation.exists', ['attribute' => __('engagement format')])],
'errors' => ['format' => __('validation.exists', ['attribute' => __('engagement format')])],
],
]);
];
});
20 changes: 10 additions & 10 deletions tests/Datasets/StoreEngagementLanguagesRequestValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php

dataset('storeEngagementLanguagesRequestValidationErrors', function () {
return array_map('array_values', [
'Languages is missing' => [
return [
'Languages is missing' => fn () => [
'state' => ['languages' => null],
'errors' => fn () => ['languages' => __('validation.required', ['attribute' => __('languages')])],
'errors' => ['languages' => __('validation.required', ['attribute' => __('languages')])],
],
'Languages is not an array' => [
'Languages is not an array' => fn () => [
'state' => ['languages' => false],
'errors' => fn () => ['languages' => __('validation.array', ['attribute' => __('languages')])],
'errors' => ['languages' => __('validation.array', ['attribute' => __('languages')])],
],
'Languages is empty' => [
'Languages is empty' => fn () => [
'state' => ['languages' => []],
'errors' => fn () => ['languages' => __('validation.required', ['attribute' => __('languages')])],
'errors' => ['languages' => __('validation.required', ['attribute' => __('languages')])],
],
'Language is invalid' => [
'Language is invalid' => fn () => [
'state' => ['languages' => ['xyz']],
'errors' => fn () => ['languages.0' => __('validation.exists', ['attribute' => __('languages')])],
'errors' => ['languages.0' => __('validation.exists', ['attribute' => __('languages')])],
],
]);
];
});
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

dataset('storeEngagementRecruitmentRequestValidationErrors', function () {
return array_map('array_values', [
'Recruitment is missing' => [
return [
'Recruitment is missing' => fn () => [
'state' => ['recruitment' => null],
'errors' => fn () => ['recruitment' => __('validation.required', ['attribute' => __('recruitment method')])],
'errors' => ['recruitment' => __('validation.required', ['attribute' => __('recruitment method')])],
],
'Recruitment is invalid' => [
'Recruitment is invalid' => fn () => [
'state' => ['recruitment' => ['xyz']],
'errors' => fn () => ['recruitment' => __('validation.exists', ['attribute' => __('recruitment method')])],
'errors' => ['recruitment' => __('validation.exists', ['attribute' => __('recruitment method')])],
],
]);
];
});
28 changes: 14 additions & 14 deletions tests/Datasets/StoreEngagementRequestValidationErrors.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<?php

dataset('storeEngagementRequestValidationErrors', function () {
return array_map('array_values', [
'Project id is missing' => [
return [
'Project id is missing' => fn () => [
'state' => ['project_id' => null],
'errors' => fn () => ['project_id' => __('validation.required', ['attribute' => __('project id')])],
'errors' => ['project_id' => __('validation.required', ['attribute' => __('project id')])],
],
'Project id is invalid' => [
'Project id is invalid' => fn () => [
'state' => ['project_id' => 100000],
'errors' => fn () => ['project_id' => __('validation.exists', ['attribute' => __('project id')])],
'errors' => ['project_id' => __('validation.exists', ['attribute' => __('project id')])],
],
'Name is not a string' => [
'Name is not a string' => fn () => [
'state' => ['name' => ['en' => 123]],
'errors' => fn () => ['name.en' => __('validation.string', ['attribute' => __('engagement name (English)')])],
'errors' => ['name.en' => __('validation.string', ['attribute' => __('engagement name (English)')])],
],
'Name is missing required translation' => [
'Name is missing required translation' => fn () => [
'state' => ['name' => ['es' => 'Nombre del compromiso']],
'errors' => fn () => [
'errors' => [
'name.en' => __('An engagement name must be provided in at least one language.'),
'name.fr' => __('An engagement name must be provided in at least one language.'),
],
],
'Who is missing' => [
'Who is missing' => fn () => [
'state' => ['who' => null],
'errors' => fn () => ['who' => __('You must indicate who you want to engage.')],
'errors' => ['who' => __('You must indicate who you want to engage.')],
],
'Who is invalid' => [
'Who is invalid' => fn () => [
'state' => ['who' => 'other'],
'errors' => fn () => ['who' => __('validation.exists', ['attribute' => __('who')])],
'errors' => ['who' => __('validation.exists', ['attribute' => __('who')])],
],
]);
];
});
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

dataset('storeOrganizationLanguagesRequestValidationErrors', function () {
return array_map('array_values', [
'Languages is missing' => [
return [
'Languages is missing' => fn () => [
'state' => ['roles' => null],
'errors' => fn () => ['languages' => __('validation.required', ['attribute' => __('languages')])],
'errors' => ['languages' => __('validation.required', ['attribute' => __('languages')])],
],
'Languages is not an array' => [
'Languages is not an array' => fn () => [
'state' => ['languages' => false],
'errors' => fn () => ['languages' => __('validation.array', ['attribute' => __('languages')])],
'errors' => ['languages' => __('validation.array', ['attribute' => __('languages')])],
],
'Languages is empty' => [
'Languages is empty' => fn () => [
'state' => ['languages' => []],
'errors' => fn () => ['languages' => __('validation.required', ['attribute' => __('languages')])],
'errors' => ['languages' => __('validation.required', ['attribute' => __('languages')])],
],
]);
];
});
Loading

0 comments on commit a0861a4

Please sign in to comment.