From 2f2de8ccfea4b0efec9eaaacbcfd330e0be0bcb9 Mon Sep 17 00:00:00 2001 From: jkavalik Date: Wed, 9 Oct 2024 09:59:42 +0200 Subject: [PATCH] replaced getBy(Id)/assertNotNull by their checked variant --- .../cases/integration/Entity/entity.compositePK.phpt | 12 ++++-------- tests/cases/integration/Entity/entity.pk.phpt | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/tests/cases/integration/Entity/entity.compositePK.phpt b/tests/cases/integration/Entity/entity.compositePK.phpt index b6605cbf..f799d12c 100644 --- a/tests/cases/integration/Entity/entity.compositePK.phpt +++ b/tests/cases/integration/Entity/entity.compositePK.phpt @@ -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; @@ -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; @@ -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; @@ -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'); diff --git a/tests/cases/integration/Entity/entity.pk.phpt b/tests/cases/integration/Entity/entity.pk.phpt index ad09a51a..a9215ca5 100644 --- a/tests/cases/integration/Entity/entity.pk.phpt +++ b/tests/cases/integration/Entity/entity.pk.phpt @@ -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);