brilo-example/tests/Db/Users/UserRepositoryTest.php

39 lines
987 B
PHP
Raw Permalink Normal View History

2024-08-02 12:13:25 +00:00
<?php
declare(strict_types=1);
namespace App\Tests\Db\Users;
use App\Repository\Users\UserRepository;
use App\Tests\Common\DatabaseTestTrait;
use App\Tests\Common\FakerTrait;
use App\Tests\Common\Generators\UserGeneratorTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class UserRepositoryTest extends KernelTestCase
{
use FakerTrait;
use DatabaseTestTrait;
use UserGeneratorTrait;
protected function setUp(): void
{
parent::bootKernel();
$this->bootFaker();
$this->bootDatabase();
}
public function testFindByIdsWillReturnOnlyIdsWhichExists(): void
{
$user = $this->createUser(1);
/**
* @var UserRepository $userRepository
*/
$userRepository = parent::getContainer()->get(UserRepository::class);
$result = $userRepository->findByIds([1, /* non existent ids */ 2]);
$this->assertCount(1, $result);
$this->assertSame(1, $result[1]->id);
}
}