mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-18 02:05:36 +00:00
test: add phpunit
This commit is contained in:
parent
ada68af9b4
commit
08bd2a4541
@ -44,7 +44,7 @@ use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
readonly class RDAPService
|
||||
class RDAPService
|
||||
{
|
||||
/* @see https://www.iana.org/domains/root/db */
|
||||
public const ISO_TLD_EXCEPTION = ['ac', 'eu', 'uk', 'su', 'tp'];
|
||||
|
||||
@ -13,6 +13,15 @@
|
||||
"src/ApiResource/.gitignore"
|
||||
]
|
||||
},
|
||||
"doctrine/deprecations": {
|
||||
"version": "1.1",
|
||||
"recipe": {
|
||||
"repo": "github.com/symfony/recipes",
|
||||
"branch": "main",
|
||||
"version": "1.0",
|
||||
"ref": "87424683adc81d7dc305eefec1fced883084aab9"
|
||||
}
|
||||
},
|
||||
"doctrine/doctrine-bundle": {
|
||||
"version": "2.12",
|
||||
"recipe": {
|
||||
|
||||
75
tests/Service/DomainTest.php
Normal file
75
tests/Service/DomainTest.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Service;
|
||||
|
||||
use App\Entity\Domain;
|
||||
use App\Entity\DomainEvent;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class DomainTest extends TestCase
|
||||
{
|
||||
|
||||
public function testIsRedemptionPeriod(): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
(new Domain())
|
||||
->setStatus(['redemption period'])
|
||||
->isRedemptionPeriod()
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
(new Domain())
|
||||
->setStatus(['active'])
|
||||
->isRedemptionPeriod()
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsPendingDelete(): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
(new Domain())
|
||||
->setStatus(['pending delete'])
|
||||
->isPendingDelete()
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
(new Domain())
|
||||
->setStatus(['active'])
|
||||
->isPendingDelete()
|
||||
);
|
||||
|
||||
$this->assertFalse(
|
||||
(new Domain())
|
||||
->setStatus(['redemption period', 'pending delete'])
|
||||
->isPendingDelete()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function testGetExpiresInDays(): void
|
||||
{
|
||||
$this->assertNull(
|
||||
(new Domain())
|
||||
->setDeleted(true)
|
||||
->getExpiresInDays()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
90, // Expiration date (10 days) + Auto Renew Period (45 days) + Redemption Period (30 days) + Pending Delete Period (10 days)
|
||||
(new Domain())
|
||||
->addEvent(
|
||||
(new DomainEvent())
|
||||
->setDate((new DateTimeImmutable())->add(new DateInterval('P10D')))
|
||||
->setAction('expiration')
|
||||
->setDeleted(false)
|
||||
)->getExpiresInDays()
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user