Skip to content

Commit

Permalink
replaced getBy(Id)/assertNotNull by their checked variant
Browse files Browse the repository at this point in the history
  • Loading branch information
jkavalik committed Oct 9, 2024
1 parent f987af7 commit 2f2de8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 4 additions & 8 deletions tests/cases/integration/Entity/entity.compositePK.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class EntityCompositePKTest extends DataTestCase

$this->orm->clear();

$userStat = $this->orm->userStats->getBy(['user' => $userId, 'date' => $at]);
Assert::notNull($userStat);
$userStat = $this->orm->userStats->getByChecked(['user' => $userId, 'date' => $at]);
Assert::type(DateTimeImmutable::class, $userStat->id[1]);

$userStat->value = 101;
Expand All @@ -76,8 +75,7 @@ class EntityCompositePKTest extends DataTestCase

$this->orm->clear();

$res = $this->orm->userStatsX->getBy(['date' => new DateTime('2019-01-01')]);
Assert::notNull($res);
$res = $this->orm->userStatsX->getByChecked(['date' => new DateTime('2019-01-01')]);
Assert::same(100, $res->value);

$res->value = 200;
Expand All @@ -86,8 +84,7 @@ class EntityCompositePKTest extends DataTestCase

$this->orm->clear();

$res = $this->orm->userStatsX->getBy(['date' => new DateTime('2019-01-01')]);
Assert::notNull($res);
$res = $this->orm->userStatsX->getByChecked(['date' => new DateTime('2019-01-01')]);
Assert::same(200, $res->value);

Environment::$checkAssertions = false;
Expand All @@ -97,8 +94,7 @@ class EntityCompositePKTest extends DataTestCase

public function testGetBy(): void
{
$tagFollower = $this->orm->tagFollowers->getBy(['tag' => 3, 'author' => 1]);
Assert::notNull($tagFollower);
$tagFollower = $this->orm->tagFollowers->getByChecked(['tag' => 3, 'author' => 1]);
Assert::same($tagFollower->tag->name, 'Tag 3');
Assert::same($tagFollower->author->name, 'Writer 1');

Expand Down
3 changes: 1 addition & 2 deletions tests/cases/integration/Entity/entity.pk.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class EntityPkTest extends DataTestCase
$this->orm->persistAndFlush($timeSeries);

$this->orm->clear();
$timeSeries = $this->orm->timeSeries->getById($datetime);
Assert::notNull($timeSeries);
$timeSeries = $this->orm->timeSeries->getByIdChecked($datetime);
$timeSeries->value = 5;
$this->orm->persistAndFlush($timeSeries);

Expand Down

0 comments on commit 2f2de8c

Please sign in to comment.