您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CompanySetupAndBehaviorTest.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. use App\Models\Accounting\Transaction;
  3. it('initially assigns a personal company to the test user', function () {
  4. $testUser = $this->testUser;
  5. $testCompany = $this->testCompany;
  6. expect($testUser)->not->toBeNull()
  7. ->and($testCompany)->not->toBeNull()
  8. ->and($testCompany->personal_company)->toBeTrue()
  9. ->and($testUser->currentCompany->id)->toBe($testCompany->id);
  10. });
  11. it('can create a new company and switches to it automatically', function () {
  12. $testUser = $this->testUser;
  13. $testCompany = $this->testCompany;
  14. $newCompany = createCompany('New Company');
  15. expect($newCompany)->not->toBeNull()
  16. ->and($newCompany->name)->toBe('New Company')
  17. ->and($newCompany->personal_company)->toBeFalse()
  18. ->and($testUser->currentCompany->id)->toBe($newCompany->id)
  19. ->and($newCompany->id)->not->toBe($testCompany->id);
  20. });
  21. it('returns data for the current company based on the CurrentCompanyScope', function () {
  22. $testUser = $this->testUser;
  23. $testCompany = $this->testCompany;
  24. Transaction::factory()
  25. ->forCompanyAndBankAccount($testCompany, $testCompany->default->bankAccount)
  26. ->count(10)
  27. ->create();
  28. $newCompany = createCompany('New Company');
  29. expect($testUser->currentCompany->id)
  30. ->toBe($newCompany->id)
  31. ->not->toBe($testCompany->id);
  32. Transaction::factory()
  33. ->forCompanyAndBankAccount($newCompany, $newCompany->default->bankAccount)
  34. ->count(5)
  35. ->create();
  36. expect(Transaction::count())->toBe(5);
  37. $testUser->switchCompany($testCompany);
  38. expect($testUser->currentCompany->id)->toBe($testCompany->id)
  39. ->and(Transaction::count())->toBe(10);
  40. });
  41. it('validates that company default settings are non-null', function () {
  42. $testCompany = $this->testCompany;
  43. expect($testCompany->profile->country)->not->toBeNull()
  44. ->and($testCompany->profile->email)->not->toBeNull()
  45. ->and($testCompany->default->currency_code)->toBe('USD')
  46. ->and($testCompany->locale->language)->toBe('en')
  47. ->and($testCompany->default->bankAccount->account->name)->toBe('Cash on Hand');
  48. });