Skip to content

Commit b2cb18e

Browse files
committed
Pint updates
1 parent 84d3648 commit b2cb18e

35 files changed

+850
-887
lines changed

tests/Eloquent/AggregationTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
use PDPhilip\Elasticsearch\Schema\Schema;
65
use Workbench\App\Models\Product;
76

87
test('retrieve distinct product statuses', function () {

tests/Eloquent/NestedTest.php

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,84 @@
11
<?php
22

3-
use Workbench\App\Models\BlogPost;
4-
use Workbench\App\Models\Product;
3+
use Workbench\App\Models\BlogPost;
54

6-
test('retrieve blog posts with specific comments', function () {
5+
test('retrieve blog posts with specific comments', function () {
76
BlogPost::factory()->create([
8-
'comments' => [
9-
['name' => 'John Doe', 'country' => 'Peru', 'likes' => 5],
10-
['name' => 'Jane Smith', 'country' => 'USA', 'likes' => 3]
11-
]
12-
]);
7+
'comments' => [
8+
['name' => 'John Doe', 'country' => 'Peru', 'likes' => 5],
9+
['name' => 'Jane Smith', 'country' => 'USA', 'likes' => 3],
10+
],
11+
]);
1312

1413
$posts = BlogPost::whereNestedObject('comments', function ($query) {
15-
$query->where('country', 'Peru')->where('likes', 5);
14+
$query->where('country', 'Peru')->where('likes', 5);
1615
})->get();
1716

1817
expect($posts)->toHaveCount(1)
19-
->and($posts->first()->comments[0]['country'])->toEqual('Peru')
20-
->and($posts->first()->comments[0]['likes'])->toEqual(5);
21-
});
18+
->and($posts->first()->comments[0]['country'])->toEqual('Peru')
19+
->and($posts->first()->comments[0]['likes'])->toEqual(5);
20+
});
2221

23-
test('exclude blog posts with comments from a specific country', function () {
22+
test('exclude blog posts with comments from a specific country', function () {
2423
BlogPost::factory()->create([
25-
'comments' => [
26-
['name' => 'John Doe', 'country' => 'Peru', 'likes' => 5]
27-
]
28-
]);
24+
'comments' => [
25+
['name' => 'John Doe', 'country' => 'Peru', 'likes' => 5],
26+
],
27+
]);
2928

3029
$posts = BlogPost::whereNotNestedObject('comments', function ($query) {
31-
$query->where('country', 'Peru');
30+
$query->where('country', 'Peru');
3231
})->get();
3332

3433
expect($posts->isNotEmpty())->toBeTrue();
35-
});
34+
});
3635

37-
test('order blog posts by comments likes descending', function () {
36+
test('order blog posts by comments likes descending', function () {
3837
BlogPost::factory()->create([
39-
'status' => 1,
40-
'comments' => [
41-
['name' => 'John Doe', 'country' => 'Peru', 'likes' => 5],
42-
['name' => 'Jane Smith', 'country' => 'USA', 'likes' => 8]
43-
]
44-
]);
38+
'status' => 1,
39+
'comments' => [
40+
['name' => 'John Doe', 'country' => 'Peru', 'likes' => 5],
41+
['name' => 'Jane Smith', 'country' => 'USA', 'likes' => 8],
42+
],
43+
]);
4544

4645
// FIXME: @pdphilip I can't get this to sort for the life of me not sure what I am doing wrong.
4746
$posts = BlogPost::where('status', 1)->orderByNested('comments.likes', 'desc', 'sum')->get();
4847
expect($posts->first()->comments[0]['likes'])->toEqual(8);
49-
})->todo();
48+
})->todo();
5049

51-
test('filter blog posts by comments from Switzerland ordered by likes', function () {
50+
test('filter blog posts by comments from Switzerland ordered by likes', function () {
5251
BlogPost::factory()->create([
53-
'status' => 5,
54-
'comments' => [
55-
['name' => 'April Von', 'country' => 'Switzerland', 'likes' => 10],
56-
['name' => 'Mabelle Schinner', 'country' => 'Switzerland', 'likes' => 7]
57-
]
58-
]);
52+
'status' => 5,
53+
'comments' => [
54+
['name' => 'April Von', 'country' => 'Switzerland', 'likes' => 10],
55+
['name' => 'Mabelle Schinner', 'country' => 'Switzerland', 'likes' => 7],
56+
],
57+
]);
5958

6059
$post = BlogPost::where('status', 5)->queryNested('comments', function ($query) {
61-
$query->where('country', 'Switzerland')->orderBy('likes');
60+
$query->where('country', 'Switzerland')->orderBy('likes');
6261
})->first();
6362

6463
expect($post->comments[0]['name'])->toEqual('Mabelle Schinner')
65-
->and($post->comments[0]['likes'])->toEqual(7)
66-
->and($post->comments[1]['likes'])->toEqual(10);
67-
});
64+
->and($post->comments[0]['likes'])->toEqual(7)
65+
->and($post->comments[1]['likes'])->toEqual(10);
66+
});
6867

69-
test('filter comments with likes greater than or equal to 5, limit 2', function () {
68+
test('filter comments with likes greater than or equal to 5, limit 2', function () {
7069
BlogPost::factory()->create([
71-
'status' => 5,
72-
'comments' => [
73-
['name' => 'Damaris Ondricka', 'country' => 'Peru', 'likes' => 5],
74-
['name' => 'April Von', 'country' => 'Switzerland', 'likes' => 10],
75-
['name' => 'Third Comment', 'country' => 'USA', 'likes' => 2]
76-
]
77-
]);
70+
'status' => 5,
71+
'comments' => [
72+
['name' => 'Damaris Ondricka', 'country' => 'Peru', 'likes' => 5],
73+
['name' => 'April Von', 'country' => 'Switzerland', 'likes' => 10],
74+
['name' => 'Third Comment', 'country' => 'USA', 'likes' => 2],
75+
],
76+
]);
7877

7978
$post = BlogPost::where('status', 5)->queryNested('comments', function ($query) {
80-
$query->where('likes', '>=', 5)->limit(2);
79+
$query->where('likes', '>=', 5)->limit(2);
8180
})->first();
8281

8382
expect($post->comments)->toHaveCount(2)
84-
->and($post->comments[0]['likes'])->toBeGreaterThanOrEqual(5);
85-
});
83+
->and($post->comments[0]['likes'])->toBeGreaterThanOrEqual(5);
84+
});

tests/Eloquent/QueryingTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
use PDPhilip\Elasticsearch\Schema\Schema;
65
use Workbench\App\Models\Product;
76

87
test('retrieve all products', function () {
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
<?php
22

3-
declare(strict_types=1);
3+
declare(strict_types=1);
44

5-
use Workbench\App\Models\Company;
6-
use Workbench\App\Models\CompanyLog;
7-
use Workbench\App\Models\CompanyProfile;
8-
use Workbench\App\Models\Avatar;
9-
use Workbench\App\Models\Photo;
5+
use Workbench\App\Models\Avatar;
6+
use Workbench\App\Models\Company;
7+
use Workbench\App\Models\CompanyLog;
8+
use Workbench\App\Models\CompanyProfile;
9+
use Workbench\App\Models\Photo;
1010

11-
test('company has many company logs', function () {
11+
test('company has many company logs', function () {
1212
$company = Company::factory()->create();
1313
$logs = CompanyLog::factory(3)->create(['company_id' => $company->_id]);
1414
$fetchedLogs = $company->companyLogs;
1515

1616
expect($fetchedLogs)->toHaveCount(3)
17-
->and($fetchedLogs->first())->toBeInstanceOf(CompanyLog::class);
18-
});
17+
->and($fetchedLogs->first())->toBeInstanceOf(CompanyLog::class);
18+
});
1919

20-
test('company has one company profile', function () {
20+
test('company has one company profile', function () {
2121
$company = Company::factory()->create();
2222
$profile = CompanyProfile::factory()->create(['company_id' => $company->_id]);
2323
$fetchedProfile = $company->companyProfile;
2424

2525
expect($fetchedProfile)->toBeInstanceOf(CompanyProfile::class)
26-
->and($fetchedProfile->_id)->toEqual($profile->_id);
27-
});
26+
->and($fetchedProfile->_id)->toEqual($profile->_id);
27+
});
2828

29-
test('company has one avatar using morphOne', function () {
29+
test('company has one avatar using morphOne', function () {
3030
$company = Company::factory()->create();
3131
$avatar = Avatar::factory()->create(['imageable_id' => $company->_id, 'imageable_type' => Company::class]);
3232
$fetchedAvatar = $company->avatar;
3333

3434
expect($fetchedAvatar)->toBeInstanceOf(Avatar::class)
35-
->and($fetchedAvatar->_id)->toEqual($avatar->_id);
36-
});
35+
->and($fetchedAvatar->_id)->toEqual($avatar->_id);
36+
});
3737

38-
test('company has many photos using morphMany', function () {
38+
test('company has many photos using morphMany', function () {
3939
$company = Company::factory()->create();
4040
$photos = Photo::factory(5)->create(['photoable_id' => $company->_id, 'photoable_type' => Company::class]);
4141
$fetchedPhotos = $company->photos;
4242

4343
expect($fetchedPhotos)->toHaveCount(5)
44-
->and($fetchedPhotos->first())->toBeInstanceOf(Photo::class);
45-
});
44+
->and($fetchedPhotos->first())->toBeInstanceOf(Photo::class);
45+
});

tests/Eloquent/SaveTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
declare(strict_types=1);
44

5-
use PDPhilip\Elasticsearch\Schema\Schema;
65
use Workbench\App\Models\Product;
76

87
test('save a new product with individual attributes', function () {
9-
$product = new Product();
8+
$product = new Product;
109
$product->name = 'New Product';
1110
$product->price = 199.99;
1211
$product->status = 1;
@@ -50,7 +49,7 @@
5049
});
5150

5251
test('save product without waiting for index refresh', function () {
53-
$product = new Product();
52+
$product = new Product;
5453
$product->name = 'Fast Save Product';
5554
$product->status = 1;
5655
$product->saveWithoutRefresh();
@@ -97,7 +96,7 @@
9796
});
9897

9998
test('ensure save without refresh accurately models elastic behavior', function () {
100-
$product = new Product();
99+
$product = new Product;
101100
$product->name = 'Delayed Visibility Product';
102101
$product->price = 150;
103102
$product->saveWithoutRefresh();

0 commit comments

Comments
 (0)