diff --git a/app/Utils/Traits/CompanySettingsSaver.php b/app/Utils/Traits/CompanySettingsSaver.php index 67f628ae1908..5dd2bad44033 100644 --- a/app/Utils/Traits/CompanySettingsSaver.php +++ b/app/Utils/Traits/CompanySettingsSaver.php @@ -120,6 +120,9 @@ trait CompanySettingsSaver elseif (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter') { $value = 'integer'; + if($key == 'besr_id') + $value = 'string'; + if (! property_exists($settings, $key)) { continue; } elseif (! $this->checkAttribute($value, $settings->{$key})) { @@ -187,6 +190,9 @@ trait CompanySettingsSaver if($key == 'gmail_sending_user_id') $value = 'string'; + if($key == 'besr_id') + $value = 'string'; + if (! property_exists($settings, $key)) { continue; } elseif ($this->checkAttribute($value, $settings->{$key})) { diff --git a/app/Utils/Traits/SettingsSaver.php b/app/Utils/Traits/SettingsSaver.php index cb6af5ebb3aa..e507a90677cf 100644 --- a/app/Utils/Traits/SettingsSaver.php +++ b/app/Utils/Traits/SettingsSaver.php @@ -55,7 +55,7 @@ trait SettingsSaver elseif (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter' || ($key == 'payment_terms' && strlen($settings->{$key}) >= 1) || ($key == 'valid_until' && strlen($settings->{$key}) >= 1)) { $value = 'integer'; - if($key == 'gmail_sending_user_id') + if($key == 'gmail_sending_user_id' || $key == 'besr_id') $value = 'string'; if (! property_exists($settings, $key)) { diff --git a/tests/Feature/CompanySettingsTest.php b/tests/Feature/CompanySettingsTest.php index 80c753bb72db..9a546d046117 100644 --- a/tests/Feature/CompanySettingsTest.php +++ b/tests/Feature/CompanySettingsTest.php @@ -56,7 +56,7 @@ class CompanySettingsTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); + ])->putJson('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); } @@ -78,11 +78,13 @@ class CompanySettingsTest extends TestCase $this->company->saveSettings($settings, $this->company); + $response = false; + try { $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); + ])->putJson('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); } catch (ValidationException $e) { $message = json_decode($e->validator->getMessageBag(), 1); nlog($message); @@ -109,7 +111,7 @@ class CompanySettingsTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); + ])->putJson('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); $response->assertStatus(200); @@ -135,7 +137,7 @@ class CompanySettingsTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); + ])->putJson('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); $response->assertStatus(200); @@ -162,7 +164,7 @@ class CompanySettingsTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->put('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); + ])->putJson('/api/v1/companies/'.$this->encodePrimaryKey($this->company->id), $this->company->toArray()); $response->assertStatus(200); @@ -185,7 +187,7 @@ class CompanySettingsTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->post('/api/v1/companies?include=company', $this->company->toArray()); + ])->postJson('/api/v1/companies?include=company', $this->company->toArray()); $arr = $response->json(); $response->assertStatus(200); @@ -203,7 +205,7 @@ class CompanySettingsTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->post('/api/v1/companies?include=company', $this->company->toArray()); + ])->postJson('/api/v1/companies?include=company', $this->company->toArray()); $arr = $response->json(); $response->assertStatus(200); @@ -221,7 +223,7 @@ class CompanySettingsTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->post('/api/v1/companies?include=company', $this->company->toArray()); + ])->postJson('/api/v1/companies?include=company', $this->company->toArray()); $arr = $response->json(); $response->assertStatus(200); @@ -239,7 +241,7 @@ class CompanySettingsTest extends TestCase $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-Token' => $this->token, - ])->post('/api/v1/companies?include=company', $this->company->toArray()); + ])->postJson('/api/v1/companies?include=company', $this->company->toArray()); $arr = $response->json(); $response->assertStatus(200);