[TESTS] Fix Entity test in accordance with the changes to createOrUpdate

This commit is contained in:
Hugo Sales 2021-08-07 18:46:49 +00:00
parent b5de80303a
commit 57f43108bb
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -23,7 +23,6 @@ namespace App\Tests\Core;
use App\Core\DB\DB; use App\Core\DB\DB;
use App\Entity\LocalUser; use App\Entity\LocalUser;
use App\Util\Exception\NotFoundException;
use App\Util\GNUsocialTestCase; use App\Util\GNUsocialTestCase;
use Jchook\AssertThrows\AssertThrows; use Jchook\AssertThrows\AssertThrows;
@ -48,11 +47,14 @@ class EntityTest extends GNUsocialTestCase
public function testCreateOrUpdate() public function testCreateOrUpdate()
{ {
$user = LocalUser::createOrUpdate(['nickname' => 'taken_user']); [$user, $is_update] = LocalUser::createOrUpdate(['nickname' => 'taken_user']);
static::assertNotNull($user); static::assertNotNull($user);
static::assertThrows(NotFoundException::class, fn () => LocalUser::createOrUpdate(['nickname' => 'taken_user', 'outgoing_email' => 'foo@bar'])); static::assertTrue($is_update);
$user = LocalUser::createOrUpdate(['nickname' => 'taken_user', 'outgoing_email' => 'foo@bar'], find_by_keys: ['nickname']); [, $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::assertSame('foo@bar', $user->getOutgoingEmail());
static::assertTrue($is_update);
} }
public function testGetWithPK() public function testGetWithPK()