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

3
tests/unit/Test.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
include_once 'TestEmail.php';
include_once 'TestUser.php';

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')
);
}
}

16
tests/unit/TestUser.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use model\forum\User;
final class TestUser extends TestCase
{
public function testCanBeCreatedFromValidEmailAddress(): void
{
$this->assertInstanceOf(
User::class,
new User(1, 'andreas', 'andreas@example.com', 'password', '10-04-2019 12:00:00', '10-04-2019 12:00:00', '94.212.253.51', -1, 1)
);
}
}