mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Fixes for client store request
This commit is contained in:
parent
c28bf391fb
commit
e844abf27d
@ -89,8 +89,6 @@ class StoreClientRequest extends Request
|
||||
protected function prepareForValidation()
|
||||
{
|
||||
$input = $this->all();
|
||||
|
||||
//@todo implement feature permissions for > 50 clients
|
||||
|
||||
$settings = ClientSettings::defaults();
|
||||
|
||||
@ -133,6 +131,10 @@ class StoreClientRequest extends Request
|
||||
$input['shipping_country_id'] = $this->getCountryCode($input['shipping_country_code']);
|
||||
}
|
||||
|
||||
/* If there is no number, just unset it here. */
|
||||
if(array_key_exists('number', $input) && ( is_null($input['number']) || empty($input['number'])))
|
||||
unset($input['number']);
|
||||
|
||||
$this->replace($input);
|
||||
}
|
||||
|
||||
|
@ -36,8 +36,6 @@ trait GeneratesCounter
|
||||
//todo in the form validation, we need to ensure that if a prefix and pattern is set we throw a validation error,
|
||||
//only one type is allow else this will cause confusion to the end user
|
||||
|
||||
|
||||
|
||||
private function getNextEntityNumber($entity, Client $client, $is_recurring = false)
|
||||
{
|
||||
$prefix = '';
|
||||
|
@ -68,6 +68,56 @@ class ClientApiTest extends TestCase
|
||||
}
|
||||
|
||||
|
||||
public function testClientNoneValidation()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'name' => $this->faker->firstName,
|
||||
'number' => '',
|
||||
];
|
||||
|
||||
$response = false;
|
||||
|
||||
try{
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/clients/', $data);
|
||||
} catch (ValidationException $e) {
|
||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||
nlog($message);
|
||||
}
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testClientNullValidation()
|
||||
{
|
||||
|
||||
$data = [
|
||||
'name' => $this->faker->firstName,
|
||||
'number' => null,
|
||||
];
|
||||
|
||||
$response = false;
|
||||
|
||||
try{
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/clients/', $data);
|
||||
} catch (ValidationException $e) {
|
||||
$message = json_decode($e->validator->getMessageBag(), 1);
|
||||
nlog($message);
|
||||
}
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function testClientCountryCodeValidationTrueIso3()
|
||||
{
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user