-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrea Pollastri
committed
Nov 13, 2023
1 parent
5f24221
commit ed0c82c
Showing
3 changed files
with
102 additions
and
1 deletion.
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,45 @@ | ||
<?php | ||
|
||
namespace Axiostudio\FatturaElettronica\Tests; | ||
|
||
use Axiostudio\FatturaElettronica\Models\Id; | ||
use Axiostudio\FatturaElettronica\Settings; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Validator\Validation; | ||
|
||
class IdTest extends TestCase | ||
{ | ||
public function testConstructorWithIdPaese(): void | ||
{ | ||
$idCodice = 'ABC123456789'; | ||
$idPaese = 'IT'; | ||
|
||
$id = new Id($idCodice, $idPaese); | ||
|
||
$this->assertInstanceOf(Id::class, $id); | ||
$this->assertEquals($idCodice, $id->IdCodice); | ||
$this->assertEquals($idPaese, $id->IdPaese); | ||
} | ||
|
||
public function testConstructorWithoutIdPaese(): void | ||
{ | ||
$idCodice = 'ABC123456789'; | ||
|
||
$id = new Id($idCodice); | ||
|
||
$this->assertInstanceOf(Id::class, $id); | ||
$this->assertEquals($idCodice, $id->IdCodice); | ||
$this->assertEquals(Settings::IdPaeseDefault(), $id->IdPaese); | ||
} | ||
|
||
public function testValidation(): void | ||
{ | ||
$id = new Id('ABC123456789', 'IT'); | ||
|
||
$validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator(); | ||
|
||
$violations = $validator->validate($id); | ||
|
||
$this->assertCount(0, $violations); | ||
} | ||
} |
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 | ||
|
||
namespace Axiostudio\FatturaElettronica\Tests; | ||
|
||
use Axiostudio\FatturaElettronica\Models\Sede; | ||
use Axiostudio\FatturaElettronica\Settings; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Validator\Validation; | ||
|
||
class SedeTest extends TestCase | ||
{ | ||
public function testConstructorWithProvinciaAndNazione(): void | ||
{ | ||
$indirizzo = 'Via Example, 123'; | ||
$cap = '12345'; | ||
$comune = 'Example City'; | ||
$provincia = 'EX'; | ||
$nazione = 'IT'; | ||
|
||
$sede = new Sede($indirizzo, $cap, $comune, $provincia, $nazione); | ||
|
||
$this->assertInstanceOf(Sede::class, $sede); | ||
$this->assertEquals($indirizzo, $sede->Indirizzo); | ||
$this->assertEquals($cap, $sede->CAP); | ||
$this->assertEquals($comune, $sede->Comune); | ||
$this->assertEquals($provincia, $sede->Provincia); | ||
$this->assertEquals($nazione, $sede->Nazione); | ||
} | ||
|
||
public function testConstructorWithoutProvinciaAndNazione(): void | ||
{ | ||
$indirizzo = 'Via Example, 123'; | ||
$cap = '12345'; | ||
$comune = 'Example City'; | ||
|
||
$sede = new Sede($indirizzo, $cap, $comune); | ||
|
||
$this->assertInstanceOf(Sede::class, $sede); | ||
$this->assertEquals($indirizzo, $sede->Indirizzo); | ||
$this->assertEquals($cap, $sede->CAP); | ||
$this->assertEquals($comune, $sede->Comune); | ||
$this->assertNull($sede->Provincia); | ||
$this->assertEquals(Settings::IdPaeseDefault(), $sede->Nazione); | ||
} | ||
|
||
public function testValidation(): void | ||
{ | ||
$sede = new Sede('Via Example, 123', '12345', 'Example City', 'EX', 'IT'); | ||
|
||
$validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator(); | ||
|
||
$violations = $validator->validate($sede); | ||
|
||
$this->assertCount(0, $violations); | ||
} | ||
} |