|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +use BiiiiiigMonster\Hasin\Tests\Models\Country; |
| 4 | +use BiiiiiigMonster\Hasin\Tests\Models\Image; |
| 5 | +use BiiiiiigMonster\Hasin\Tests\Models\Supplier; |
3 | 6 | use BiiiiiigMonster\Hasin\Tests\Models\User; |
| 7 | +use BiiiiiigMonster\Hasin\Tests\Models\Video; |
4 | 8 |
|
5 | | -test('hasIn same as has', function () { |
| 9 | +test('HasMany: hasIn same as has', function () { |
6 | 10 | $has = User::has('posts')->orderBy('id')->pluck('id'); |
7 | 11 | $hasIn = User::hasIn('posts')->orderBy('id')->pluck('id'); |
8 | 12 |
|
9 | 13 | expect($has)->toEqual($hasIn); |
10 | 14 | }); |
11 | 15 |
|
| 16 | +test('HasOne: hasIn same as has', function () { |
| 17 | + $has = User::has('phone')->orderBy('id')->pluck('id'); |
| 18 | + $hasIn = User::hasIn('phone')->orderBy('id')->pluck('id'); |
| 19 | + |
| 20 | + expect($has)->toEqual($hasIn); |
| 21 | +}); |
| 22 | + |
| 23 | +test('BelongsTo: hasIn same as has', function () { |
| 24 | + $has = User::has('country')->orderBy('id')->pluck('id'); |
| 25 | + $hasIn = User::hasIn('country')->orderBy('id')->pluck('id'); |
| 26 | + |
| 27 | + expect($has)->toEqual($hasIn); |
| 28 | +}); |
| 29 | + |
| 30 | +test('BelongsToMany: hasIn same as has', function () { |
| 31 | + $has = User::has('roles')->orderBy('id')->pluck('id'); |
| 32 | + $hasIn = User::hasIn('roles')->orderBy('id')->pluck('id'); |
| 33 | + |
| 34 | + expect($has)->toEqual($hasIn); |
| 35 | +}); |
| 36 | + |
| 37 | +test('HasOneThrough: hasIn same as has', function () { |
| 38 | + $has = Supplier::has('userHistory')->orderBy('id')->pluck('id'); |
| 39 | + $hasIn = Supplier::hasIn('userHistory')->orderBy('id')->pluck('id'); |
| 40 | + |
| 41 | + expect($has)->toEqual($hasIn); |
| 42 | +}); |
| 43 | + |
| 44 | +test('HasManyThrough: hasIn same as has', function () { |
| 45 | + $has = Country::has('posts')->orderBy('id')->pluck('id'); |
| 46 | + $hasIn = Country::hasIn('posts')->orderBy('id')->pluck('id'); |
| 47 | + |
| 48 | + expect($has)->toEqual($hasIn); |
| 49 | +}); |
| 50 | + |
| 51 | +test('MorphOne: hasIn same as has', function () { |
| 52 | + $has = User::has('image')->orderBy('id')->pluck('id'); |
| 53 | + $hasIn = User::hasIn('image')->orderBy('id')->pluck('id'); |
| 54 | + |
| 55 | + expect($has)->toEqual($hasIn); |
| 56 | +}); |
| 57 | + |
| 58 | +test('MorphTo: hasIn same as has', function () { |
| 59 | + $has = Image::has('imageable')->orderBy('id')->pluck('id'); |
| 60 | + $hasIn = Image::hasIn('imageable')->orderBy('id')->pluck('id'); |
| 61 | + |
| 62 | + expect($has)->toEqual($hasIn); |
| 63 | +}); |
| 64 | + |
| 65 | +test('MorphMany: hasIn same as has', function () { |
| 66 | + $has = Video::has('comments')->orderBy('id')->pluck('id'); |
| 67 | + $hasIn = Video::hasIn('comments')->orderBy('id')->pluck('id'); |
| 68 | + |
| 69 | + expect($has)->toEqual($hasIn); |
| 70 | +}); |
| 71 | + |
| 72 | +test('MorphToMany: hasIn same as has', function () { |
| 73 | + $has = Video::has('tags')->orderBy('id')->pluck('id'); |
| 74 | + $hasIn = Video::hasIn('tags')->orderBy('id')->pluck('id'); |
| 75 | + |
| 76 | + expect($has)->toEqual($hasIn); |
| 77 | +}); |
| 78 | + |
12 | 79 | test('hasIn(gte 2) same as has(gte 2)', function () { |
13 | 80 | $has = User::has('posts', '>=', 2)->orderBy('id')->pluck('id'); |
14 | 81 | $hasIn = User::hasIn('posts', '>=', 2)->orderBy('id')->pluck('id'); |
|
0 commit comments