1
0
Fork 0

PHPunit example

This commit is contained in:
Marcel Kapfer 2021-09-16 22:45:25 +02:00
parent d88b89209b
commit f61eea9169
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09
2 changed files with 60 additions and 0 deletions

27
tests/EmailTest.php Normal file
View file

@ -0,0 +1,27 @@
<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use MMK2410\MyTodoList\Email;
final class EmailTest extends TestCase
{
private $email = 'user@example.com';
public function testCanBeCreatedFromValidEmailAddress(): void {
$this->assertInstanceOf(
Email::class,
Email::fromString($this->email)
);
}
public function testCannotBeCreatedFromInvalidEmailAddress(): void {
$this->expectException(InvalidArgumentException::class);
Email::fromString('invalid');
}
public function testCanBeUsedAsString(): void {
$this->assertEquals(
$this->email,
Email::fromString($this->email)
);
}
}