Some Test Case Fixed
This commit is contained in:
parent
d07280bc92
commit
67ec7bc543
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Webkul\Core\Contracts\Validations;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\Rule;
|
||||||
|
|
||||||
|
class PhoneNumber implements Rule
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the validation rule passes.
|
||||||
|
*
|
||||||
|
* @param string $attribute
|
||||||
|
* @param mixed $value
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function passes($attribute, $value)
|
||||||
|
{
|
||||||
|
return preg_match('%^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$%i', $value) && strlen($value) >= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation error message.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function message()
|
||||||
|
{
|
||||||
|
return trans('core::validation.phone-number');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,5 +4,6 @@ return [
|
||||||
'alpha-numeric-space' => 'The :attribute can only accept alpha, numeric and spaces.',
|
'alpha-numeric-space' => 'The :attribute can only accept alpha, numeric and spaces.',
|
||||||
'code' => 'The :attribute must be valid.',
|
'code' => 'The :attribute must be valid.',
|
||||||
'decimal' => 'The :attribute must be valid.',
|
'decimal' => 'The :attribute must be valid.',
|
||||||
|
'phone-number' => 'The :attribute must be valid phone number.',
|
||||||
'slug' => 'The :attribute must be valid slug.',
|
'slug' => 'The :attribute must be valid slug.',
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ namespace Webkul\Customer\Http\Requests;
|
||||||
|
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
use Webkul\Core\Contracts\Validations\AlphaNumericSpace;
|
use Webkul\Core\Contracts\Validations\AlphaNumericSpace;
|
||||||
|
use Webkul\Core\Contracts\Validations\PhoneNumber;
|
||||||
use Webkul\Customer\Rules\VatIdRule;
|
use Webkul\Customer\Rules\VatIdRule;
|
||||||
|
|
||||||
class CustomerAddressRequest extends FormRequest
|
class CustomerAddressRequest extends FormRequest
|
||||||
|
|
@ -35,7 +36,7 @@ class CustomerAddressRequest extends FormRequest
|
||||||
'state' => ['required', 'alpha'],
|
'state' => ['required', 'alpha'],
|
||||||
'city' => ['required', new AlphaNumericSpace],
|
'city' => ['required', new AlphaNumericSpace],
|
||||||
'postcode' => ['required', 'numeric'],
|
'postcode' => ['required', 'numeric'],
|
||||||
'phone' => ['required', 'numeric'],
|
'phone' => ['required', new PhoneNumber],
|
||||||
'vat_id' => [new VatIdRule()],
|
'vat_id' => [new VatIdRule()],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,15 +52,15 @@ class CustomerCest
|
||||||
$I->click('Add Address');
|
$I->click('Add Address');
|
||||||
|
|
||||||
$this->fields = [
|
$this->fields = [
|
||||||
'company_name' => $faker->company,
|
'company_name' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->company),
|
||||||
'first_name' => $faker->firstName,
|
'first_name' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->firstName),
|
||||||
'last_name' => $faker->lastName,
|
'last_name' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->lastName),
|
||||||
'vat_id' => 'INVALIDVAT',
|
'vat_id' => 'INVALIDVAT',
|
||||||
'address1[]' => $faker->streetName,
|
'address1[]' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->streetAddress),
|
||||||
'country' => $faker->countryCode,
|
'country' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->countryCode),
|
||||||
'state' => $faker->state,
|
'state' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->state),
|
||||||
'city' => $faker->city,
|
'city' => preg_replace('/[^A-Za-z0-9 ]/', '', $faker->city),
|
||||||
'postcode' => $faker->postcode,
|
'postcode' => preg_replace('/[^0-9]/', '', $faker->postcode),
|
||||||
'phone' => $faker->phoneNumber,
|
'phone' => $faker->phoneNumber,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -99,7 +99,7 @@ class CustomerCest
|
||||||
$I->click('Edit');
|
$I->click('Edit');
|
||||||
|
|
||||||
$oldcompany = $this->fields['company_name'];
|
$oldcompany = $this->fields['company_name'];
|
||||||
$this->fields['company_name'] = $faker->company;
|
$this->fields['company_name'] = preg_replace('/[^A-Za-z0-9 ]/', '', $faker->company);
|
||||||
|
|
||||||
$I->submitForm($formCssSelector, $this->fields);
|
$I->submitForm($formCssSelector, $this->fields);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue