enforce settype() for strings that are _ids (#3010)

* Add Includes

* Clean up company settings + tests

* Update Company Settings Schema

* Fixes for tests

* fixes for tests

* fixes for settings

* Enforce settype(string) for _ids
This commit is contained in:
David Bomba 2019-10-23 17:21:16 +11:00 committed by GitHub
parent e4f0b08d3e
commit 9dfa97eedf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -123,7 +123,12 @@ trait SettingsSaver
continue;
}
elseif($this->checkAttribute($value, $settings->{$key})){
settype($settings->{$key}, $value);
if(substr($key, -3) == '_id')
settype($settings->{$key}, 'string');
else
settype($settings->{$key}, $value);
}
else {
unset($settings->{$key});

View File

@ -119,6 +119,8 @@ class CompanyTest extends TestCase
$settings = new \stdClass;
$settings->custom_value1 = 'test';
$settings->invoice_design_id = '2';
$settings->quote_design_id = 1;
$company->settings = $settings;
@ -128,7 +130,14 @@ class CompanyTest extends TestCase
])->put('/api/v1/companies/'.$this->encodePrimaryKey($company->id), $company->toArray())
->assertStatus(200)->decodeResponseJson();
\Log::error($response);
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $token,
])->get('/api/v1/companies/'.$this->encodePrimaryKey($company->id))
->assertStatus(200)->decodeResponseJson();
//\Log::error($response);
//$this->assertEquals(1, $response['data']['size_id']);