From 57f43108bb7ace12e9c4cc093eead588dc1dceb6 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sat, 7 Aug 2021 18:46:49 +0000 Subject: [PATCH] [TESTS] Fix Entity test in accordance with the changes to createOrUpdate --- tests/Core/EntityTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/Core/EntityTest.php b/tests/Core/EntityTest.php index 38bc8ef0a8..5341546cc7 100644 --- a/tests/Core/EntityTest.php +++ b/tests/Core/EntityTest.php @@ -23,7 +23,6 @@ namespace App\Tests\Core; use App\Core\DB\DB; use App\Entity\LocalUser; -use App\Util\Exception\NotFoundException; use App\Util\GNUsocialTestCase; use Jchook\AssertThrows\AssertThrows; @@ -48,11 +47,14 @@ class EntityTest extends GNUsocialTestCase public function testCreateOrUpdate() { - $user = LocalUser::createOrUpdate(['nickname' => 'taken_user']); + [$user, $is_update] = LocalUser::createOrUpdate(['nickname' => 'taken_user']); static::assertNotNull($user); - static::assertThrows(NotFoundException::class, fn () => LocalUser::createOrUpdate(['nickname' => 'taken_user', 'outgoing_email' => 'foo@bar'])); - $user = LocalUser::createOrUpdate(['nickname' => 'taken_user', 'outgoing_email' => 'foo@bar'], find_by_keys: ['nickname']); + static::assertTrue($is_update); + [, $is_update] = LocalUser::createOrUpdate(['nickname' => 'taken_user', 'outgoing_email' => 'foo@bar']); + static::assertFalse($is_update); + [$user, $is_update] = LocalUser::createOrUpdate(['nickname' => 'taken_user', 'outgoing_email' => 'foo@bar'], find_by_keys: ['nickname']); static::assertSame('foo@bar', $user->getOutgoingEmail()); + static::assertTrue($is_update); } public function testGetWithPK()