Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 39 additions & 18 deletions tests/DomainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,25 @@ public function testEdgecaseDomains(): void

public function testEdgecaseDomainsError(): void
{
$this->expectException('Exception');
$this->expectExceptionMessage("'http://httpmydomain.com' must be a valid domain or hostname");
$domain = new Domain('http://httpmydomain.com');
try {
$domain = new Domain('http://httpmydomain.com');
$this->fail('Expected exception was not thrown');
} catch (Exception $e) {
$this->assertEquals(
"'http://httpmydomain.com' must be a valid domain or hostname",
$e->getMessage()
);
}
}

public function testEdgecaseDomainsError2(): void
{
$this->expectException('Exception');
$this->expectExceptionMessage("'https://httpmydomain.com' must be a valid domain or hostname");
$domain = new Domain('https://httpmydomain.com');
try {
$domain = new Domain('https://httpmydomain.com');
$this->fail("Expected exception not thrown.");
} catch (Exception $e) {
$this->assertEquals("'https://httpmydomain.com' must be a valid domain or hostname", $e->getMessage());
}
}

public function testExampleCoUk(): void
Expand Down Expand Up @@ -186,30 +195,42 @@ public function testPrivateTLD(): void

public function testHTTPException1(): void
{
$this->expectException(Exception::class);

new Domain('http://www.facbook.com');
try {
new Domain('http://www.facbook.com');
$this->fail('Expected exception was not thrown');
} catch (Exception $e) {
$this->assertInstanceOf(Exception::class, $e);
}
}

public function testHTTPException2(): void
{
$this->expectException(Exception::class);

new Domain('http://facbook.com');
try {
new Domain('http://facbook.com');
$this->fail('Expected exception was not thrown');
} catch (Exception $e) {
$this->assertInstanceOf(Exception::class, $e);
}
}

public function testHTTPSException1(): void
{
$this->expectException(Exception::class);

new Domain('https://www.facbook.com');
try {
new Domain('https://www.facbook.com');
$this->fail('Expected exception was not thrown');
} catch (Exception $e) {
$this->assertInstanceOf(Exception::class, $e);
}
}

public function testHTTPSException2(): void
{
$this->expectException(Exception::class);

new Domain('https://facbook.com');
try {
new Domain('https://facbook.com');
$this->fail('Expected exception was not thrown');
} catch (Exception $e) {
$this->assertInstanceOf(Exception::class, $e);
}
}

public function testExampleExampleCk(): void
Expand Down