Repository navigation
Expand file tree
/
Copy pathDomainTest.php
More file actions
52 lines (42 loc) · 2.29 KB
/
Copy pathDomainTest.php
File metadata and controls
52 lines (42 loc) · 2.29 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
<?php
namespace Dingo\Api\Tests\Http\Validation;
use Illuminate\Http\Request;
use PHPUnit_Framework_TestCase;
use Dingo\Api\Http\Validation\Domain;
class DomainTest extends PHPUnit_Framework_TestCase
{
public function testValidationFailsWithInvalidOrNullDomain()
{
$validator = new Domain('http://foo.bar');
$this->assertFalse($validator->validate(Request::create('http://bar.foo', 'GET')), 'Validation passed when it should have failed with an invalid domain.');
$validator = new Domain(null);
$this->assertFalse($validator->validate(Request::create('http://bar.foo', 'GET')), 'Validation passed when it should have failed with a null domain.');
}
public function testValidationPasses()
{
$validator = new Domain('http://foo.bar');
$this->assertTrue($validator->validate(Request::create('http://foo.bar', 'GET')), 'Validation failed when it should have passed with a valid domain.');
}
public function testValidationPassesWithDifferentProtocols()
{
$validator = new Domain('ftp://foo.bar');
$this->assertTrue($validator->validate(Request::create('http://foo.bar', 'GET')), 'Validation failed when it should have passed with a valid domain.');
$validator = new Domain('https://foo.bar');
$this->assertTrue($validator->validate(Request::create('http://foo.bar', 'GET')), 'Validation failed when it should have passed with a valid domain.');
}
public function testValidationPassesWithPortOnDomain()
{
$validator = new Domain('http://foo.bar:8888');
$this->assertTrue($validator->validate(Request::create('http://foo.bar', 'GET')), 'Validation failed when it should have passed with a valid domain.');
}
public function testValidationPassesWithPortOnRequest()
{
$validator = new Domain('http://foo.bar');
$this->assertTrue($validator->validate(Request::create('http://foo.bar:8888', 'GET')), 'Validation failed when it should have passed with a valid domain.');
}
public function testValidationPassesWithPortOnDomainAndRequest()
{
$validator = new Domain('http://foo.bar:8888');
$this->assertTrue($validator->validate(Request::create('http://foo.bar:8888', 'GET')), 'Validation failed when it should have passed with a valid domain.');
}
}