Fixes for tests

This commit is contained in:
David Bomba 2023-10-26 21:09:22 +11:00
parent 0d2bc0151a
commit 8e6ae34a33
6 changed files with 41 additions and 4 deletions

View File

@ -38,8 +38,21 @@ class StoreVendorRequest extends Request
$user = auth()->user();
$rules = [];
$rules['contacts'] = 'bail|array';
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
$rules['contacts.*.password'] = [
'bail',
'nullable',
'sometimes',
'string',
'min:7', // must be at least 10 characters in length
'regex:/[a-z]/', // must contain at least one lowercase letter
'regex:/[A-Z]/', // must contain at least one uppercase letter
'regex:/[0-9]/', // must contain at least one digit
//'regex:/[@$!%*#?&.]/', // must contain a special character
];
if (isset($this->number)) {
$rules['number'] = Rule::unique('vendors')->where('company_id', $user->company()->id);

View File

@ -45,7 +45,20 @@ class UpdateVendorRequest extends Request
$rules['number'] = Rule::unique('vendors')->where('company_id', $user->company()->id)->ignore($this->vendor->id);
}
$rules['contacts.*.email'] = 'nullable|distinct';
$rules['contacts'] = 'bail|array';
$rules['contacts.*.email'] = 'bail|nullable|distinct|sometimes|email';
$rules['contacts.*.password'] = [
'bail',
'nullable',
'sometimes',
'string',
'min:7', // must be at least 10 characters in length
'regex:/[a-z]/', // must contain at least one lowercase letter
'regex:/[A-Z]/', // must contain at least one uppercase letter
'regex:/[0-9]/', // must contain at least one digit
//'regex:/[@$!%*#?&.]/', // must contain a special character
];
$rules['currency_id'] = 'bail|sometimes|exists:currencies,id';
if ($this->file('documents') && is_array($this->file('documents'))) {

View File

@ -61,13 +61,23 @@ class VendorContactRepository extends BaseRepository
$update_contact->contact_key = Str::random(40);
}
if (array_key_exists('email', $contact) && is_null($contact['email'])) {
$contact['email'] = '';
}
$update_contact->fill($contact);
if (array_key_exists('password', $contact) && strlen($contact['password']) > 1) {
$update_contact->password = Hash::make($contact['password']);
$vendor->company->vendor_contacts()->where('email', $update_contact->email)->update(['password' => $update_contact->password]);
}
if (array_key_exists('email', $contact)) {
$update_contact->email = trim($contact['email']);
}
$update_contact->saveQuietly();
});
$vendor->load('contacts');

View File

@ -927,7 +927,7 @@ class PdfBuilder
*/
private function getProductEntityDetails(): self
{
if ($this->service->config->entity_string == 'invoice') {
if (in_array($this->service->config->entity_string, ['recurring_invoice', 'invoice'])) {
$this->mergeSections([
'entity-details' => [
'id' => 'entity-details',

View File

@ -45,6 +45,7 @@ class VendorContactTransformer extends EntityTransformer
'custom_value4' => $vendor->custom_value4 ?: '',
'link' => $vendor->getLoginLink(),
'last_login' => (int)$vendor->last_login,
'password' => empty($vendor->password) ? '' : '**********',
];
}
}

View File

@ -3,7 +3,7 @@
// This is global bootstrap for autoloading
use Codeception\Util\Fixtures;
Fixtures::add('url', 'http://www.ninja.test');
Fixtures::add('url', 'http://localhost');
Fixtures::add('username', 'user@example.com');
Fixtures::add('password', 'password');