mirror of
https://github.com/jbcr/core.git
synced 2026-03-26 09:52:10 +01:00
Changed the repository method to accept the credential(string) and has the storage engine compare the lowercase values. At least this is consistent to the strings compared so it should be a consistent experience
47 lines
1.6 KiB
PHP
47 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Bolt\Tests\Repository;
|
|
|
|
use Bolt\Entity\User;
|
|
use Bolt\Tests\DbAwareTestCase;
|
|
|
|
class UserRepositoryTest extends DbAwareTestCase
|
|
{
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
|
|
// fixtures loading takes a lot of time, it would be better to load database dump for tests
|
|
self::runCommand('doctrine:fixtures:load --no-interaction --group=without-images');
|
|
}
|
|
|
|
public function testFindOneByUsername()
|
|
{
|
|
$admin = $this->getEm()->getRepository(User::class)->findOneByUsername('admin');
|
|
$this->assertInstanceOf(User::class, $admin);
|
|
|
|
$administrator = $this->getEm()->getRepository(User::class)->findOneByUsername('administrator');
|
|
$this->assertNull($administrator);
|
|
}
|
|
|
|
public function testFindOneByCredentials()
|
|
{
|
|
$admin = $this->getEm()->getRepository(User::class)->findOneByCredentials('admin');
|
|
$this->assertInstanceOf(User::class, $admin);
|
|
|
|
$adminEmail = $this->getEm()->getRepository(User::class)->findOneByCredentials('admin@example.org');
|
|
$this->assertInstanceOf(User::class, $adminEmail);
|
|
|
|
$janeAdmin = $this->getEm()->getRepository(User::class)->findOneByCredentials('Jane_Admin');
|
|
$this->assertInstanceOf(User::class, $janeAdmin);
|
|
|
|
$janeAdminEmail = $this->getEm()->getRepository(User::class)->findOneByCredentials('Jane_Admin@Example.Org');
|
|
$this->assertInstanceOf(User::class, $janeAdminEmail);
|
|
|
|
$administrator = $this->getEm()->getRepository(User::class)->findOneByCredentials('administrator');
|
|
$this->assertNull($administrator);
|
|
}
|
|
}
|