Skip to content

Commit

Permalink
Update BaseModelTest.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Jan 30, 2025
1 parent 6cd4cee commit f40da94
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions tests/Unit/Abstract/Models/BaseModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@
$target = Book::factory()->createOne();

expect(
Book::newModelInstance()->resolveRouteBindingQuery(
Book::query(),
Book::newModelInstance()->resolveRouteBinding(
hashids()->encode($target->getKey()),
)->first()->is($target),
)->is($target),
)->toBeTrue();
});

Expand All @@ -106,7 +105,7 @@ function (bool $enabled, bool $incrementing, bool $isHashedId, bool $expectation
expect(
Book::newModelInstance()
->setIncrementing($incrementing)
->shouldResolveRouteBindingAsHashedId(!$isHashedId ?: hashids()->encode(1)),
->shouldProcessHashIdRouteBinding(!$isHashedId ?: hashids()->encode(1)),
)->toBe($expectation, "Enabled: {$enabled}, Incrementing: {$incrementing}");
},
)->with([
Expand Down Expand Up @@ -137,11 +136,10 @@ function (string $value, string|null $field, Book $target): void {
config(['apiato.hash-id' => true]);

expect(
Book::newModelInstance()->resolveRouteBindingQuery(
Book::query(),
Book::newModelInstance()->resolveRouteBinding(
$value,
$field,
)->first()->is($target),
)->is($target),
)->toBeTrue();
},
)->with([
Expand Down Expand Up @@ -170,17 +168,15 @@ function () {
]);

expect(
Book::newModelInstance()->resolveRouteBindingQuery(
Book::query(),
Book::newModelInstance()->resolveRouteBinding(
$target->getKey(),
)->first()->is($target),
)->is($target),
)->toBeTrue()
->and(
Book::newModelInstance()->resolveRouteBindingQuery(
Book::query(),
Book::newModelInstance()->resolveRouteBinding(
$target->title,
'title',
)->first()->is($target),
)->is($target),
)->toBeTrue();
});
});
Expand Down

0 comments on commit f40da94

Please sign in to comment.