/vendor/aura/uri/tests/Aura/Uri/Url/FactoryTest.php |
@@ -0,0 +1,135 @@ |
<?php |
namespace Aura\Uri\Url; |
|
use Aura\Uri\PublicSuffixList; |
|
/** |
* Test class for Factory. |
* Generated by PHPUnit on 2012-07-21 at 17:13:55. |
*/ |
class FactoryTest extends \PHPUnit_Framework_TestCase |
{ |
protected function newFactory($server = []) |
{ |
$psl = new PublicSuffixList([]); |
return new Factory($server, $psl); |
} |
|
/** |
* @covers Aura\Uri\Url\Factory::newInstance |
*/ |
public function testNewInstance() |
{ |
$factory = $this->newFactory([]); |
$spec = 'http://anonymous:guest@example.com/path/to/index.php/foo/bar.xml?baz=dib#anchor'; |
$url = $factory->newInstance($spec); |
$this->assertTrue($url instanceof \Aura\Uri\Url); |
} |
|
/** |
* @covers Aura\Uri\Url\Factory::newCurrent |
*/ |
public function testNewCurrent() |
{ |
$factory = $this->newFactory([ |
'HTTP_HOST' => 'example.com', |
'REQUEST_URI' => '/path/to/index.php/foo/bar.xml?baz=dib', |
]); |
|
$url = $factory->newCurrent(); |
$actual = $url->__toString(); |
$expect = 'http://example.com/path/to/index.php/foo/bar.xml?baz=dib'; |
$this->assertSame($expect, $actual); |
} |
|
public function testNewCurrent_https() |
{ |
$factory = $this->newFactory([ |
'HTTPS' => 'on', |
'HTTP_HOST' => 'example.com', |
'REQUEST_URI' => '/path/to/index.php/foo/bar.xml?baz=dib', |
]); |
|
$url = $factory->newCurrent(); |
$actual = $url->__toString(); |
$expect = 'https://example.com/path/to/index.php/foo/bar.xml?baz=dib'; |
$this->assertSame($expect, $actual); |
} |
|
public function testNewCurrent_ssl() |
{ |
$factory = $this->newFactory([ |
'SERVER_PORT' => '443', |
'HTTP_HOST' => 'example.com', |
'REQUEST_URI' => '/path/to/index.php/foo/bar.xml?baz=dib', |
]); |
|
$url = $factory->newCurrent(); |
$actual = $url->__toString(); |
$expect = 'https://example.com/path/to/index.php/foo/bar.xml?baz=dib'; |
$this->assertSame($expect, $actual); |
} |
|
public function testNewCurrent_noHttpHost() |
{ |
$factory = $this->newFactory([ |
'REQUEST_URI' => '/path/to/index.php/foo/bar.xml?baz=dib', |
]); |
|
$url = $factory->newCurrent(); |
$actual = $url->__toString(); |
$expect = ''; |
$this->assertSame($expect, $actual); |
} |
|
public function testNewCurrent_noRequestUri() |
{ |
$factory = $this->newFactory([ |
'HTTP_HOST' => 'example.com', |
]); |
|
$url = $factory->newCurrent(); |
$actual = $url->__toString(); |
$expect = 'http://example.com'; |
$this->assertSame($expect, $actual); |
} |
|
public function testIssue9() |
{ |
$factory = $this->newFactory([ |
'HTTP_HOST' => 'example.com', |
]); |
$string = 'http://localhost:8000/site/foo/bar'; |
$url = $factory->newInstance($string); |
$this->assertSame(array('site', 'foo', 'bar'), $url->path->getArrayCopy()); |
} |
|
public function testNewInstance_noScheme() |
{ |
$factory = $this->newFactory([]); |
$string = 'example.com'; |
$url = $factory->newInstance($string); |
$actual = $url->__toString(); |
$expect = 'http://example.com'; |
$this->assertSame($expect, $actual); |
} |
|
public function testNewInstance_schemeless() |
{ |
$factory = $this->newFactory([]); |
$string = '//example.com'; |
$url = $factory->newInstance($string); |
$actual = $url->__toString(); |
$expect = 'http://example.com'; |
$this->assertSame($expect, $actual); |
} |
|
public function testNewInstance_ftpUrl() |
{ |
$factory = $this->newFactory([]); |
$string = 'ftp://ftp.example.com'; |
$url = $factory->newInstance($string); |
$actual = $url->__toString(); |
$this->assertSame($string, $actual); |
} |
} |