-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds unit tests for sealEntity entity. (#655)
- Loading branch information
1 parent
889faa5
commit 4b54f12
Showing
2 changed files
with
106 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Unit\Entity; | ||
|
||
use App\Entity\Agent; | ||
use App\Entity\Seal; | ||
use App\Tests\AbstractWebTestCase; | ||
use DateTime; | ||
use DateTimeImmutable; | ||
use Symfony\Component\Uid\Uuid; | ||
|
||
class SealTest extends AbstractWebTestCase | ||
{ | ||
public function testGettersAndSettersFromSealEntityShouldBeSuccessful(): void | ||
{ | ||
$seal = new Seal(); | ||
|
||
$id = Uuid::v4(); | ||
$name = 'Seal XXX'; | ||
$description = 'This is description of a test seal'; | ||
$agent = new Agent(); | ||
$agentId = Uuid::v4(); | ||
$expirationDate = new DateTimeImmutable('+6 month'); | ||
$createdAt = new DateTimeImmutable(); | ||
$updatedAt = new DateTime(); | ||
$deletedAt = new DateTime(); | ||
|
||
$seal->setId($id); | ||
$seal->setName($name); | ||
$seal->setDescription($description); | ||
$seal->setActive(true); | ||
$agent->setId($agentId); | ||
$seal->setCreatedBy($agent); | ||
$seal->setExpirationDate($expirationDate); | ||
$seal->setCreatedAt($createdAt); | ||
$seal->setUpdatedAt($updatedAt); | ||
$seal->setDeletedAt($deletedAt); | ||
|
||
$this->assertEquals($createdAt, $seal->getCreatedAt()); | ||
$this->assertInstanceOf(DateTimeImmutable::class, $seal->getCreatedAt()); | ||
|
||
$this->assertEquals([ | ||
'id' => $id->toRfc4122(), | ||
'name' => $name, | ||
'description' => $description, | ||
'createdBy' => $agentId->toRfc4122(), | ||
'expirationDate' => $expirationDate->format('Y-m-d H:i:s'), | ||
'createdAt' => $createdAt->format('Y-m-d H:i:s'), | ||
'updatedAt' => $updatedAt->format('Y-m-d H:i:s'), | ||
'deletedAt' => $deletedAt->format('Y-m-d H:i:s'), | ||
'active' => true, | ||
], $seal->toArray()); | ||
} | ||
} |