build version 400

This commit is contained in:
Mohit Panjwani
2020-12-02 17:54:08 +05:30
parent 326508e567
commit 89ee58590c
963 changed files with 62887 additions and 48868 deletions

View File

@ -0,0 +1,56 @@
<?php
use Crater\Models\User;
use Crater\Models\CompanySetting;
use Crater\Models\Company;
use Illuminate\Support\Facades\Artisan;
use Laravel\Sanctum\Sanctum;
use function Pest\Faker\faker;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
$user = User::find(1);
$this->withHeaders([
'company' => $user->company_id,
]);
Sanctum::actingAs(
$user,
['*']
);
});
test('company setting belongs to company', function () {
$setting = CompanySetting::factory()->create();
$this->assertTrue($setting->company()->exists());
});
test('set settings', function () {
$key = faker()->name;
$value = faker()->word;
$company = Company::factory()->create();
CompanySetting::setSettings([$key => $value], $company->id);
$response = CompanySetting::getSetting($key, $company->id);
$this->assertEquals($value, $response);
});
test('get settings', function () {
$key = faker()->name;
$value = faker()->word;
$company = Company::factory()->create();
CompanySetting::setSettings([$key => $value], $company->id);
$response = CompanySetting::getSettings([$key], $company->id);
$this->assertEquals([$key => $value], $response);
});