|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the login-cidadao project or it's bundles. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Guilherme Donato <guilhermednt on github> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace LoginCidadao\RemoteClaimsBundle\Tests\Model; |
|
12
|
|
|
|
|
13
|
|
|
use LoginCidadao\RemoteClaimsBundle\Model\HttpUri; |
|
14
|
|
|
|
|
15
|
|
|
class HttpUriTest extends \PHPUnit_Framework_TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
public function testValidCompleteUri() |
|
18
|
|
|
{ |
|
19
|
|
|
$uri = 'https://user:[email protected]:8042/over/there?name=ferret#nose'; |
|
20
|
|
|
$http = HttpUri::createFromString($uri); |
|
21
|
|
|
|
|
22
|
|
|
$this->assertInstanceOf('LoginCidadao\RemoteClaimsBundle\Model\HttpUri', $http); |
|
23
|
|
|
$this->assertEquals($uri, $http->__toString()); |
|
24
|
|
|
$this->assertEquals('https', $http->getScheme()); |
|
25
|
|
|
$this->assertEquals('user:password', $http->getUserInfo()); |
|
26
|
|
|
$this->assertEquals('example.com', $http->getHost()); |
|
27
|
|
|
$this->assertEquals(8042, $http->getPort()); |
|
28
|
|
|
$this->assertEquals('user:[email protected]:8042', $http->getAuthority()); |
|
29
|
|
|
$this->assertEquals('/over/there', $http->getPath()); |
|
30
|
|
|
$this->assertEquals('name=ferret', $http->getQuery()); |
|
31
|
|
|
$this->assertEquals('nose', $http->getFragment()); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testValidSimpleUri() |
|
35
|
|
|
{ |
|
36
|
|
|
$uri = 'http://example.com'; |
|
37
|
|
|
$http = HttpUri::createFromString($uri); |
|
38
|
|
|
|
|
39
|
|
|
$this->assertInstanceOf('LoginCidadao\RemoteClaimsBundle\Model\HttpUri', $http); |
|
40
|
|
|
$this->assertEquals($uri, $http->__toString()); |
|
41
|
|
|
$this->assertEquals('http', $http->getScheme()); |
|
42
|
|
|
$this->assertEquals('', $http->getUserInfo()); |
|
43
|
|
|
$this->assertEquals('example.com', $http->getHost()); |
|
44
|
|
|
$this->assertNull($http->getPort()); |
|
45
|
|
|
$this->assertEquals('example.com', $http->getAuthority()); |
|
46
|
|
|
$this->assertEquals('', $http->getPath()); |
|
47
|
|
|
$this->assertEquals('', $http->getQuery()); |
|
48
|
|
|
$this->assertEquals('', $http->getFragment()); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
|