mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-06 14:44:37 -04:00
Tests for Vendor Locale
This commit is contained in:
parent
92336b7f05
commit
c807ae864a
@ -172,12 +172,12 @@ class Vendor extends BaseModel
|
||||
return $this->hasMany(VendorContact::class)->where('is_primary', true);
|
||||
}
|
||||
|
||||
public function documents()
|
||||
public function documents(): \Illuminate\Database\Eloquent\Relations\MorphMany
|
||||
{
|
||||
return $this->morphMany(Document::class, 'documentable');
|
||||
}
|
||||
|
||||
public function assigned_user()
|
||||
public function assigned_user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'assigned_user_id', 'id')->withTrashed();
|
||||
}
|
||||
@ -214,12 +214,12 @@ class Vendor extends BaseModel
|
||||
return $this->company->timezone();
|
||||
}
|
||||
|
||||
public function company()
|
||||
public function company(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Company::class);
|
||||
}
|
||||
|
||||
public function user()
|
||||
public function user(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class)->withTrashed();
|
||||
}
|
||||
@ -268,24 +268,29 @@ class Vendor extends BaseModel
|
||||
return $this->company->settings;
|
||||
}
|
||||
|
||||
public function purchase_order_filepath($invitation)
|
||||
public function purchase_order_filepath($invitation): string
|
||||
{
|
||||
$contact_key = $invitation->contact->contact_key;
|
||||
|
||||
return $this->company->company_key.'/'.$this->vendor_hash.'/'.$contact_key.'/purchase_orders/';
|
||||
}
|
||||
|
||||
public function locale()
|
||||
public function locale(): string
|
||||
{
|
||||
return $this->company->locale();
|
||||
return $this->language ? $this->language->locale : $this->company->locale();
|
||||
}
|
||||
|
||||
public function country()
|
||||
public function language(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Language::class);
|
||||
}
|
||||
|
||||
public function country(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Country::class);
|
||||
}
|
||||
|
||||
public function date_format()
|
||||
public function date_format(): string
|
||||
{
|
||||
return $this->company->date_format();
|
||||
}
|
||||
|
@ -42,9 +42,45 @@ class VendorApiTest extends TestCase
|
||||
$this->faker = \Faker\Factory::create();
|
||||
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
// $this->withoutExceptionHandling();
|
||||
public function testVendorLocale()
|
||||
{
|
||||
$v = \App\Models\Vendor::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
'company_id' => $this->company->id
|
||||
]);
|
||||
|
||||
$this->assertNotNull($v->locale());
|
||||
}
|
||||
|
||||
public function testVendorLocaleEn()
|
||||
{
|
||||
$v = \App\Models\Vendor::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
'company_id' => $this->company->id,
|
||||
'language_id' => '1'
|
||||
]);
|
||||
|
||||
$this->assertEquals('en', $v->locale());
|
||||
}
|
||||
|
||||
public function testVendorLocaleEnCompanyFallback()
|
||||
{
|
||||
$settings = $this->company->settings;
|
||||
$settings->language_id = '2';
|
||||
|
||||
$c = \App\Models\Company::factory()->create([
|
||||
'account_id' => $this->account->id,
|
||||
'settings' => $settings,
|
||||
]);
|
||||
|
||||
$v = \App\Models\Vendor::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
'company_id' => $c->id
|
||||
]);
|
||||
|
||||
$this->assertEquals('it', $v->locale());
|
||||
}
|
||||
|
||||
public function testVendorGetFilter()
|
||||
|
Loading…
x
Reference in New Issue
Block a user