mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-30 21:21:09 -04:00 
			
		
		
		
	build version 400
This commit is contained in:
		
							
								
								
									
										34
									
								
								tests/Unit/CompanyTest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								tests/Unit/CompanyTest.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,34 @@ | ||||
| <?php | ||||
|  | ||||
| use Crater\Models\User; | ||||
| use Crater\Models\Company; | ||||
| use Illuminate\Support\Facades\Artisan; | ||||
| use Laravel\Sanctum\Sanctum; | ||||
|  | ||||
| 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 has one user', function () { | ||||
|     $company = Company::factory()->hasUser()->create(); | ||||
|  | ||||
|     $this->assertTrue($company->user()->exists()); | ||||
| }); | ||||
|  | ||||
| test('company has many company setings', function () { | ||||
|     $company = Company::factory()->hasSettings(5)->create(); | ||||
|  | ||||
|     $this->assertCount(5, $company->settings); | ||||
|  | ||||
|     $this->assertTrue($company->settings()->exists()); | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user