PHPUnit – The PHP Testing Framework

PHOTO EMBED

Tue Jan 12 2021 05:27:40 GMT+0000 (Coordinated Universal Time)

Saved by @mvieira

<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;

final class EmailTest extends TestCase
{
    public function testCanBeCreatedFromValidEmailAddress(): void
    {
        $this->assertInstanceOf(
            Email::class,
            Email::fromString('user@example.com')
        );
    }

    public function testCannotBeCreatedFromInvalidEmailAddress(): void
    {
        $this->expectException(InvalidArgumentException::class);

        Email::fromString('invalid');
    }

    public function testCanBeUsedAsString(): void
    {
        $this->assertEquals(
            'user@example.com',
            Email::fromString('user@example.com')
        );
    }
}






content_copyCOPY

https://phpunit.de/getting-started/phpunit-9.html