1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Fixes for tests

This commit is contained in:
David Bomba 2022-06-30 17:51:39 +10:00
parent 59e3978374
commit 0894752c80
3 changed files with 18 additions and 10 deletions

View File

@ -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})) {

View File

@ -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)) {

View File

@ -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);