added phpunit and composer stuff

This commit is contained in:
2019-10-07 10:55:12 +02:00
parent 3ad68e4078
commit ef2e25ef19
9 changed files with 1633 additions and 0 deletions

30
tests/unit/TestEmail.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use model\forum\Email;
final class TestEmail extends TestCase
{
public function testCanBeCreatedFromValidEmailAddress(): void
{
$this->assertInstanceOf(
Email::class,
new Email('user@example.com')
);
}
public function testCannotBeCreatedFromInvalidEmailAddress(): void
{
$email = new Email('user');
$this->assertFalse($email->getValid());
$this->assertEquals($email->getEmail(), 'invalid');
}
public function testCanBeUsedAsString(): void
{
$this->assertEquals(
'user@example.com',
new Email('user@example.com')
);
}
}