added phpunit and composer stuff
This commit is contained in:
3
tests/unit/Test.php
Normal file
3
tests/unit/Test.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
include_once 'TestEmail.php';
|
||||
include_once 'TestUser.php';
|
||||
30
tests/unit/TestEmail.php
Normal file
30
tests/unit/TestEmail.php
Normal 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
16
tests/unit/TestUser.php
Normal 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)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user