|
1 | 1 | <?php |
2 | 2 |
|
3 | | - declare(strict_types=1); |
| 3 | +declare(strict_types=1); |
4 | 4 |
|
5 | | - use Workbench\App\Models\Avatar; |
6 | | - use Workbench\App\Models\Company; |
7 | | - use Workbench\App\Models\CompanyProfile; |
8 | | - use Workbench\App\Models\Photo; |
9 | | - use Workbench\App\Models\User; |
10 | | - use Workbench\App\Models\UserLog; |
11 | | - use Workbench\App\Models\UserProfile; |
| 5 | +use Workbench\App\Models\Avatar; |
| 6 | +use Workbench\App\Models\Company; |
| 7 | +use Workbench\App\Models\CompanyProfile; |
| 8 | +use Workbench\App\Models\Photo; |
| 9 | +use Workbench\App\Models\User; |
| 10 | +use Workbench\App\Models\UserLog; |
| 11 | +use Workbench\App\Models\UserProfile; |
12 | 12 |
|
13 | | - beforeEach(function () { |
| 13 | +beforeEach(function () { |
14 | 14 | User::truncate(); |
15 | 15 | Company::truncate(); |
16 | 16 | UserLog::truncate(); |
17 | 17 | UserProfile::truncate(); |
18 | 18 | CompanyProfile::truncate(); |
19 | 19 | Avatar::truncate(); |
20 | 20 | Photo::truncate(); |
21 | | - }); |
| 21 | +}); |
22 | 22 |
|
23 | | - it('should show user relationships to ES models', function () { |
| 23 | +it('should show user relationships to ES models', function () { |
24 | 24 |
|
25 | 25 | $usersPerCompany = 3; |
26 | 26 | $logsPerUser = 10; |
27 | 27 | $photosPerUser = 5; |
28 | 28 | $photosPerCompany = 2; |
29 | 29 |
|
30 | 30 | createCompanyData( |
31 | | - photosPerCompany: $photosPerCompany, |
32 | | - usersPerCompany : $usersPerCompany, |
33 | | - photosPerUser : $photosPerUser, |
34 | | - logsPerUser : $logsPerUser |
| 31 | + photosPerCompany: $photosPerCompany, |
| 32 | + usersPerCompany : $usersPerCompany, |
| 33 | + photosPerUser : $photosPerUser, |
| 34 | + logsPerUser : $logsPerUser |
35 | 35 | ); |
36 | 36 | $user = User::first(); |
37 | 37 |
|
38 | 38 | expect($user->company->_id)->not()->toBeEmpty() |
39 | | - ->and($user->company->avatar->_id)->not()->toBeEmpty() |
40 | | - ->and($user->photos)->not()->toBeEmpty() |
41 | | - ->and(count($user->photos))->toBe($photosPerUser) |
42 | | - ->and($user->userLogs)->not()->toBeEmpty() |
43 | | - ->and(count($user->userLogs))->toBe($logsPerUser) |
44 | | - ->and($user->userProfile->_id)->not()->toBeEmpty() |
45 | | - ->and($user->avatar->_id)->not()->toBeEmpty(); |
| 39 | + ->and($user->company->avatar->_id)->not()->toBeEmpty() |
| 40 | + ->and($user->photos)->not()->toBeEmpty() |
| 41 | + ->and(count($user->photos))->toBe($photosPerUser) |
| 42 | + ->and($user->userLogs)->not()->toBeEmpty() |
| 43 | + ->and(count($user->userLogs))->toBe($logsPerUser) |
| 44 | + ->and($user->userProfile->_id)->not()->toBeEmpty() |
| 45 | + ->and($user->avatar->_id)->not()->toBeEmpty(); |
46 | 46 |
|
47 | | - }); |
| 47 | +}); |
48 | 48 |
|
49 | | - |
50 | | - it('should show user log (ES) relationship to user', function () { |
| 49 | +it('should show user log (ES) relationship to user', function () { |
51 | 50 | $usersPerCompany = 3; |
52 | 51 | $logsPerUser = 10; |
53 | 52 | $photosPerUser = 5; |
54 | 53 | $photosPerCompany = 2; |
55 | 54 |
|
56 | 55 | createCompanyData( |
57 | | - photosPerCompany: $photosPerCompany, |
58 | | - usersPerCompany : $usersPerCompany, |
59 | | - photosPerUser : $photosPerUser, |
60 | | - logsPerUser : $logsPerUser |
| 56 | + photosPerCompany: $photosPerCompany, |
| 57 | + usersPerCompany : $usersPerCompany, |
| 58 | + photosPerUser : $photosPerUser, |
| 59 | + logsPerUser : $logsPerUser |
61 | 60 | ); |
62 | 61 |
|
63 | 62 | $userLog = UserLog::first(); |
|
66 | 65 | ->and($userLog->user->company->_id)->not()->toBeEmpty() |
67 | 66 | ->and($userLog->user->userProfile->_id)->not()->toBeEmpty() |
68 | 67 | ->and($userLog->company->_id)->not()->toBeEmpty() |
69 | | - ->and($userLog->company->users)->toHaveCount($usersPerCompany) |
70 | | - ->and($userLog->company->companyProfile->_id)->not()->toBeEmpty(); |
71 | | - |
| 68 | + ->and($userLog->company->users)->toHaveCount($usersPerCompany) |
| 69 | + ->and($userLog->company->companyProfile->_id)->not()->toBeEmpty(); |
72 | 70 |
|
73 | | - }); |
| 71 | +}); |
74 | 72 |
|
75 | | - it('should show 1 to 1 ES relationships for user and company', function () { |
| 73 | +it('should show 1 to 1 ES relationships for user and company', function () { |
76 | 74 | $usersPerCompany = 3; |
77 | 75 | $logsPerUser = 10; |
78 | 76 | $photosPerUser = 5; |
79 | 77 | $photosPerCompany = 2; |
80 | 78 |
|
81 | 79 | createCompanyData( |
82 | | - photosPerCompany: $photosPerCompany, |
83 | | - usersPerCompany : $usersPerCompany, |
84 | | - photosPerUser : $photosPerUser, |
85 | | - logsPerUser : $logsPerUser |
| 80 | + photosPerCompany: $photosPerCompany, |
| 81 | + usersPerCompany : $usersPerCompany, |
| 82 | + photosPerUser : $photosPerUser, |
| 83 | + logsPerUser : $logsPerUser |
86 | 84 | ); |
87 | 85 |
|
88 | 86 | $companyProfile = CompanyProfile::first(); |
89 | 87 | $userProfile = UserProfile::first(); |
90 | 88 |
|
91 | 89 | expect($companyProfile->company->_id)->not()->toBeEmpty() |
92 | | - ->and($userProfile->user->id)->not()->toBeEmpty(); |
| 90 | + ->and($userProfile->user->id)->not()->toBeEmpty(); |
93 | 91 |
|
94 | | - }); |
| 92 | +}); |
0 commit comments