refactor(test): apply php-cs-fixer
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

add select user by email
This commit is contained in:
Simon Vieille 2023-01-08 23:10:57 +01:00
parent f6c932314b
commit 8535ef9082
Signed by: deblan
GPG key ID: 579388D585F70417
2 changed files with 32 additions and 6 deletions

View file

@ -2,17 +2,39 @@
namespace App\Tests\Core\Auth;
use App\Repository\UserRepositoryQuery;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
/**
* @internal
* @coversNothing
*/
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
{
$client = static::createClient();
$crawler = $client->request('GET', '/admin');
$crawler = $this->client->request('GET', '/admin');
$this->assertResponseStatusCodeSame(302);
$client->followRedirect();
$this->client->followRedirect();
$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);
}
}

View file

@ -2,11 +2,15 @@
namespace App\Tests\Core\Command;
use App\Repository\UserRepositoryQuery;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
use App\Repository\UserRepositoryQuery;
/**
* @internal
* @coversNothing
*/
class CreateUserTest extends KernelTestCase
{
protected UserRepositoryQuery $query;
@ -31,7 +35,7 @@ class CreateUserTest extends KernelTestCase
'y',
'n',
]);
$commandTester->execute(['command' => $command->getName()]);
$commandTester->execute(['command' => $command->getName()]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('User created!', $output);
@ -41,7 +45,7 @@ class CreateUserTest extends KernelTestCase
'n',
'y',
]);
$commandTester->execute(['command' => $command->getName()]);
$commandTester->execute(['command' => $command->getName()]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('User created!', $output);
}