-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathDomainTest.php
More file actions
53 lines (47 loc) · 2.13 KB
/
DomainTest.php
File metadata and controls
53 lines (47 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/**
* Utopia PHP Framework
*
* @package Framework
* @subpackage Tests
*
* @link https://github.com/utopia-php/framework
* @author Appwrite Team <team@appwrite.io>
* @version 1.0 RC4
* @license The MIT License (MIT) <http://www.opensource.org/licenses/mit-license.php>
*/
namespace Utopia\Validator;
use PHPUnit\Framework\TestCase;
class DomainTest extends TestCase
{
protected Domain $domain;
public function setUp(): void
{
$this->domain = new Domain();
}
public function testIsValid()
{
// Assertions
$this->assertEquals(true, $this->domain->isValid('example.com'));
$this->assertEquals(true, $this->domain->isValid('subdomain.example.com'));
$this->assertEquals(true, $this->domain->isValid('subdomain.example-app.com'));
$this->assertEquals(true, $this->domain->isValid('subdomain-new.example.com'));
$this->assertEquals(true, $this->domain->isValid('localhost'));
$this->assertEquals(true, $this->domain->isValid('example.io'));
$this->assertEquals(true, $this->domain->isValid('example.org'));
$this->assertEquals(true, $this->domain->isValid('example.org'));
$this->assertEquals(false, $this->domain->isValid('example.com/path'));
$this->assertEquals(false, $this->domain->isValid('subdomain_new.example.com'));
$this->assertEquals(false, $this->domain->isValid('subdomain.example_app.com'));
$this->assertEquals(false, $this->domain->isValid('http://example.com'));
$this->assertEquals(false, $this->domain->isValid('https://example.com'));
$this->assertEquals(false, $this->domain->isValid('ftp://example.com'));
$this->assertEquals(false, $this->domain->isValid(false));
$this->assertEquals(false, $this->domain->isValid('.'));
$this->assertEquals(false, $this->domain->isValid('..'));
$this->assertEquals(false, $this->domain->isValid(''));
$this->assertEquals(false, $this->domain->isValid(['string', 'string']));
$this->assertEquals(false, $this->domain->isValid(1));
$this->assertEquals(false, $this->domain->isValid(1.2));
}
}