Change filtering of scalars prior to validation
This commit is contained in:
parent
4ff745de82
commit
ba24bb78f6
|
|
@ -30,16 +30,16 @@ class BaseSettings
|
|||
switch ($key) {
|
||||
case 'int':
|
||||
case 'integer':
|
||||
return (int) $value;
|
||||
return is_scalar($value) ? (int) $value : 0;
|
||||
case 'real':
|
||||
case 'float':
|
||||
case 'double':
|
||||
return (float) $value;
|
||||
return is_scalar($value) ? (float) $value : 0;
|
||||
case 'string':
|
||||
return is_null($value) ? '' : (string) $value;
|
||||
return is_scalar($value) ? (string) $value : '';
|
||||
case 'bool':
|
||||
case 'boolean':
|
||||
return boolval($value);
|
||||
return is_scalar($value) ? boolval($value) : false;
|
||||
case 'object':
|
||||
return json_decode($value);
|
||||
case 'array':
|
||||
|
|
|
|||
|
|
@ -52,6 +52,51 @@ class InvoiceTest extends TestCase
|
|||
$this->makeTestData();
|
||||
}
|
||||
|
||||
|
||||
public function testLineItemValidation()
|
||||
{
|
||||
|
||||
$line_items = [];
|
||||
|
||||
$item = new \stdClass();
|
||||
$item->quantity = 1;
|
||||
$item->cost = 100000000;
|
||||
$item->type_id = '1';
|
||||
$item->tax_name1 = ['tax_name1'];
|
||||
$item->tax_rate1 = 10;
|
||||
$item->tax_name2 = 'tax_name2';
|
||||
$item->tax_rate2 = 10;
|
||||
$item->tax_name3 = 'tax_name3';
|
||||
$item->tax_rate3 = 10;
|
||||
|
||||
$line_items[] = $item;
|
||||
|
||||
$data = [
|
||||
'status_id' => 1,
|
||||
'number' => '',
|
||||
'discount' => 0,
|
||||
'is_amount_discount' => 1,
|
||||
'po_number' => '3434343',
|
||||
'public_notes' => 'notes',
|
||||
'is_deleted' => 0,
|
||||
'custom_value1' => 0,
|
||||
'custom_value2' => 0,
|
||||
'custom_value3' => 0,
|
||||
'custom_value4' => 0,
|
||||
'client_id' => $this->client->hashed_id,
|
||||
'line_items' => $line_items,
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->postJson('/api/v1/invoices?mark_sent=true', $data)
|
||||
->assertStatus(200);
|
||||
|
||||
$arr = $response->json();
|
||||
|
||||
}
|
||||
|
||||
public function testMaxDiscount()
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue