add select user by email
This commit is contained in:
parent
f6c932314b
commit
8535ef9082
|
@ -2,17 +2,39 @@
|
||||||
|
|
||||||
namespace App\Tests\Core\Auth;
|
namespace App\Tests\Core\Auth;
|
||||||
|
|
||||||
|
use App\Repository\UserRepositoryQuery;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
class LoginTest extends WebTestCase
|
class LoginTest extends WebTestCase
|
||||||
{
|
{
|
||||||
|
protected UserRepositoryQuery $query;
|
||||||
|
protected KernelBrowser $client;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
$this->client = static::createClient();
|
||||||
|
$this->query = self::$container->get(UserRepositoryQuery::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function testLoginRedirect(): void
|
public function testLoginRedirect(): void
|
||||||
{
|
{
|
||||||
$client = static::createClient();
|
$crawler = $this->client->request('GET', '/admin');
|
||||||
$crawler = $client->request('GET', '/admin');
|
|
||||||
|
|
||||||
$this->assertResponseStatusCodeSame(302);
|
$this->assertResponseStatusCodeSame(302);
|
||||||
$client->followRedirect();
|
$this->client->followRedirect();
|
||||||
$this->assertResponseIsSuccessful();
|
$this->assertResponseIsSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLoginUser(): void
|
||||||
|
{
|
||||||
|
$user = $this->query->create()->andWhere('.email=\'admin@localhost\'')->findOne();
|
||||||
|
$this->client->loginUser($user);
|
||||||
|
$this->client->request('GET', '/admin/account/');
|
||||||
|
$this->assertResponseStatusCodeSame(200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,15 @@
|
||||||
|
|
||||||
namespace App\Tests\Core\Command;
|
namespace App\Tests\Core\Command;
|
||||||
|
|
||||||
|
use App\Repository\UserRepositoryQuery;
|
||||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
use Symfony\Component\Console\Tester\CommandTester;
|
use Symfony\Component\Console\Tester\CommandTester;
|
||||||
use App\Repository\UserRepositoryQuery;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal
|
||||||
|
* @coversNothing
|
||||||
|
*/
|
||||||
class CreateUserTest extends KernelTestCase
|
class CreateUserTest extends KernelTestCase
|
||||||
{
|
{
|
||||||
protected UserRepositoryQuery $query;
|
protected UserRepositoryQuery $query;
|
||||||
|
@ -31,7 +35,7 @@ class CreateUserTest extends KernelTestCase
|
||||||
'y',
|
'y',
|
||||||
'n',
|
'n',
|
||||||
]);
|
]);
|
||||||
$commandTester->execute(['command' => $command->getName()]);
|
$commandTester->execute(['command' => $command->getName()]);
|
||||||
$output = $commandTester->getDisplay();
|
$output = $commandTester->getDisplay();
|
||||||
$this->assertStringContainsString('User created!', $output);
|
$this->assertStringContainsString('User created!', $output);
|
||||||
|
|
||||||
|
@ -41,7 +45,7 @@ class CreateUserTest extends KernelTestCase
|
||||||
'n',
|
'n',
|
||||||
'y',
|
'y',
|
||||||
]);
|
]);
|
||||||
$commandTester->execute(['command' => $command->getName()]);
|
$commandTester->execute(['command' => $command->getName()]);
|
||||||
$output = $commandTester->getDisplay();
|
$output = $commandTester->getDisplay();
|
||||||
$this->assertStringContainsString('User created!', $output);
|
$this->assertStringContainsString('User created!', $output);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue