mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
fix: use state provider
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||
use App\Entity\Domain;
|
||||
use App\Factory\UserFactory;
|
||||
use App\Tests\AuthenticatedUserTrait;
|
||||
use App\Tests\Service\RDAPServiceTest;
|
||||
use PHPUnit\Framework\Attributes\DependsExternal;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
|
||||
final class DomainRefreshControllerTest extends ApiTestCase
|
||||
{
|
||||
use Factories;
|
||||
use AuthenticatedUserTrait;
|
||||
|
||||
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
||||
public function testRegisterDomain(): void
|
||||
{
|
||||
$testUser = UserFactory::createOne();
|
||||
$client = DomainRefreshControllerTest::createClientWithCredentials(DomainRefreshControllerTest::getToken($testUser));
|
||||
$client->request('GET', '/api/domains/example.com');
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertMatchesResourceItemJsonSchema(Domain::class);
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use ApiPlatform\Symfony\Bundle\Test\ApiTestCase;
|
||||
use App\Factory\UserFactory;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Zenstruck\Foundry\Test\Factories;
|
||||
use Zenstruck\Foundry\Test\ResetDatabase;
|
||||
|
||||
final class RegistrationControllerTest extends ApiTestCase
|
||||
{
|
||||
use ResetDatabase;
|
||||
use Factories;
|
||||
|
||||
protected static ContainerInterface $container;
|
||||
protected static EntityManagerInterface $entityManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
RegistrationControllerTest::$container = RegistrationControllerTest::getContainer();
|
||||
RegistrationControllerTest::$entityManager = RegistrationControllerTest::$container->get(EntityManagerInterface::class);
|
||||
}
|
||||
|
||||
public function testRegister(): void
|
||||
{
|
||||
$testUser = UserFactory::createOne();
|
||||
RegistrationControllerTest::$entityManager->remove($testUser);
|
||||
RegistrationControllerTest::$entityManager->flush();
|
||||
|
||||
$client = $this->createClient();
|
||||
$client->request('POST', '/api/register', [
|
||||
'json' => [
|
||||
'email' => $testUser->getEmail(),
|
||||
'password' => $testUser->getPlainPassword(),
|
||||
],
|
||||
]);
|
||||
$this->assertResponseIsSuccessful();
|
||||
$this->assertResponseStatusCodeSame(201);
|
||||
}
|
||||
|
||||
public function testRegisterEmptyEmail(): void
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->request('POST', '/api/register', [
|
||||
'json' => [
|
||||
'email' => '',
|
||||
'password' => 'MySuperPassword123',
|
||||
],
|
||||
]);
|
||||
$this->assertResponseStatusCodeSame(400);
|
||||
}
|
||||
|
||||
public function testRegisterEmptyPassword(): void
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->request('POST', '/api/register', [
|
||||
'json' => [
|
||||
'email' => 'test@domainwatchdog.eu',
|
||||
'password' => '',
|
||||
],
|
||||
]);
|
||||
$this->assertResponseStatusCodeSame(400);
|
||||
}
|
||||
|
||||
public function testRegisterWeakPassword(): void
|
||||
{
|
||||
$client = $this->createClient();
|
||||
$client->request('POST', '/api/register', [
|
||||
'json' => [
|
||||
'email' => 'test@domainwatchdog.eu',
|
||||
'password' => '123',
|
||||
],
|
||||
]);
|
||||
$this->assertResponseStatusCodeSame(400);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ final class WatchlistControllerTest extends ApiTestCase
|
||||
use Factories;
|
||||
use AuthenticatedUserTrait;
|
||||
|
||||
#[DependsExternal(RDAPServiceTest::class, 'testUpdateRdapServers')]
|
||||
public function testGetWatchlistCollection(): void
|
||||
{
|
||||
$client = $this->createUserAndWatchlist();
|
||||
@@ -77,7 +78,7 @@ final class WatchlistControllerTest extends ApiTestCase
|
||||
{
|
||||
$client = self::createClientWithCredentials(self::getToken(UserFactory::createOne()));
|
||||
$client->request('POST', '/api/watchlists', ['json' => [
|
||||
'domains' => ['/api/domains/example.com'],
|
||||
'domains' => ['/api/domains/iana.org'],
|
||||
'name' => 'My Watchlist',
|
||||
'triggers' => [
|
||||
['action' => 'email', 'event' => 'last changed'],
|
||||
|
||||
Reference in New Issue
Block a user