Skip to content

Commit a5d9117

Browse files
authored
Chore/Upgrade dependencies and improve test scripts (#28)
1 parent 078c820 commit a5d9117

7 files changed

Lines changed: 27 additions & 23 deletions

File tree

composer.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
"require": {
1414
"php": "^8.2",
1515
"ext-json": "*",
16-
"complex-heart/domain-model": "^4.0.0"
16+
"complex-heart/domain-model": "^5.0.0"
1717
},
1818
"require-dev": {
1919
"mockery/mockery": "^1.6.0",
20-
"pestphp/pest": "^2.0",
21-
"pestphp/pest-plugin-faker": "^2.0",
22-
"phpstan/phpstan": "^1.12",
20+
"pestphp/pest": "^3.8.4",
21+
"pestphp/pest-plugin-faker": "^3.0.0",
22+
"phpstan/phpstan": "^1.0",
2323
"phpstan/extension-installer": "^1.3",
24-
"phpstan/phpstan-mockery": "^1.1"
24+
"phpstan/phpstan-mockery": "^1.1",
25+
"laravel/pint": "^1.25"
2526
},
2627
"autoload": {
2728
"psr-4": {
@@ -34,9 +35,11 @@
3435
}
3536
},
3637
"scripts": {
37-
"test": "vendor/bin/pest --configuration=phpunit.xml --coverage-clover=coverage.xml --log-junit=test.xml",
38-
"test-cov": "vendor/bin/pest --configuration=phpunit.xml --coverage-html=coverage",
39-
"analyse": "vendor/bin/phpstan analyse --no-progress"
38+
"test": "vendor/bin/pest --configuration=phpunit.xml --coverage --coverage-clover=coverage.xml --log-junit=test.xml",
39+
"test-cov": "vendor/bin/pest --configuration=phpunit.xml --coverage --coverage-html=coverage",
40+
"analyse": "vendor/bin/phpstan analyse --no-progress --memory-limit=4G",
41+
"pint-test": "vendor/bin/pint --preset=psr12 --test",
42+
"pint": "vendor/bin/pint --preset=psr12"
4043
},
4144
"config": {
4245
"allow-plugins": {

src/Criteria.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static function fromSource(CriteriaSource $source): self
8787
{
8888
return self::create(
8989
groups: map(
90-
fn(array $g): FilterGroup => FilterGroup::fromArray($g),
90+
fn (array $g): FilterGroup => FilterGroup::fromArray($g),
9191
$source->filterGroups()
9292
),
9393
order: Order::create($source->orderBy(), OrderType::make($source->orderType())),
@@ -230,7 +230,7 @@ public function pageOffset(): int
230230

231231
public function __toString(): string
232232
{
233-
$groups = join('||', map(fn(FilterGroup $group): string => $group->__toString(), $this->groups));
233+
$groups = join('||', map(fn (FilterGroup $group): string => $group->__toString(), $this->groups));
234234
$order = $this->order->__toString();
235235
$page = $this->page->__toString();
236236

src/Filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static function create(string $field, Operator $operator, bool|float|int|
5252
public static function fromArray(array $filter): self
5353
{
5454
// check if the array is indexed or associative.
55-
$isIndexed = fn($source): bool => ([] !== $source) && array_keys($source) === range(0, count($source) - 1);
55+
$isIndexed = fn ($source): bool => ([] !== $source) && array_keys($source) === range(0, count($source) - 1);
5656

5757
return ($isIndexed($filter))
5858
? self::create(

src/FilterGroup.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static function create(Filter ...$filters): self
4848
public static function fromArray(array $filters): self
4949
{
5050
return self::create(
51-
...map(fn(array $filter): Filter => Filter::fromArray($filter), $filters)
51+
...map(fn (array $filter): Filter => Filter::fromArray($filter), $filters)
5252
);
5353
}
5454

@@ -60,7 +60,7 @@ public static function fromArray(array $filters): self
6060
*/
6161
public function addFilter(Filter $new): self
6262
{
63-
if ($this->filter(fn(Filter $filter): bool => $filter->equals($new))->count() > 0) {
63+
if ($this->filter(fn (Filter $filter): bool => $filter->equals($new))->count() > 0) {
6464
return $this;
6565
}
6666

@@ -196,6 +196,6 @@ public function addFilterNotContains(string $field, string $value): self
196196
*/
197197
public function __toString(): string
198198
{
199-
return join('+', map(fn(Filter $filter): string => $filter->__toString(), $this));
199+
return join('+', map(fn (Filter $filter): string => $filter->__toString(), $this));
200200
}
201201
}

src/Page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ final class Page implements ValueObject
1717
{
1818
use IsValueObject;
1919

20-
const DEFAULT_LIMIT = 25;
21-
const DEFAULT_OFFSET = 0;
20+
public const DEFAULT_LIMIT = 25;
21+
public const DEFAULT_OFFSET = 0;
2222

2323
/**
2424
* Page constructor.

tests/CriteriaTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use ComplexHeart\Domain\Criteria\Page;
1313

1414
test('Criteria should be successfully created from source.', function () {
15-
$c = Criteria::fromSource(new class implements CriteriaSource {
15+
$c = Criteria::fromSource(new class () implements CriteriaSource {
1616
public function filterGroups(): array
1717
{
1818
return [
@@ -59,7 +59,7 @@ public function pageNumber(): int
5959

6060
test('Criteria should throw exception for invalid filter groups.', function () {
6161
try {
62-
Criteria::default()->withFilterGroup(fn() => [1, 2, 3]);
62+
Criteria::default()->withFilterGroup(fn () => [1, 2, 3]);
6363
} catch (CriteriaError $e) {
6464
expect($e->violations())->toHaveCount(1);
6565
}
@@ -119,11 +119,13 @@ public function pageNumber(): int
119119

120120
test('Criteria should add or filter group to criteria object.', function () {
121121
$c = Criteria::default()
122-
->withFilterGroup(FilterGroup::create()
122+
->withFilterGroup(
123+
FilterGroup::create()
123124
->addFilterEqual('name', 'Vincent')
124125
->addFilterEqual('status', 'deceased')
125126
)
126-
->withFilterGroup(FilterGroup::create()
127+
->withFilterGroup(
128+
FilterGroup::create()
127129
->addFilterEqual('name', 'Jules')
128130
->addFilterEqual('deceased', 'alive')
129131
);
@@ -137,7 +139,8 @@ public function pageNumber(): int
137139

138140
test('Criteria should be correctly serialized to string.', function () {
139141
$c = Criteria::default()
140-
->withFilterGroup(FilterGroup::create()
142+
->withFilterGroup(
143+
FilterGroup::create()
141144
->addFilterEqual('name', 'Vincent')
142145
->addFilterGreaterOrEqualThan('age', '35')
143146
)

tests/Pest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,3 @@
3838
| global functions to help you to reduce the number of lines of code in your test files.
3939
|
4040
*/
41-
42-

0 commit comments

Comments
 (0)