Exemple #1
0
 public function testGetScheme()
 {
     $uri = new Uri('http://blog.wani.kr');
     $this->assertSame('http', $uri->getScheme());
     $uri = new Uri('https://blog.wani.kr');
     $this->assertSame('https', $uri->getScheme());
     // If no scheme is present, this method MUST return an empty string.
     $uri = new Uri('//blog.wani.kr');
     $this->assertSame('', $uri->getScheme());
     $uri = new Uri('blog.wani.kr');
     $this->assertSame('', $uri->getScheme());
     // The value returned MUST be normalized to lowercase, per RFC 3986
     // Section 3.1.
     $uri = new Uri('HTTP://blog.wani.kr');
     $this->assertSame('http', $uri->getScheme());
     // The trailing ":" character is not part of the scheme and MUST NOT be
     // added.
     $uri = new Uri('://blog.wani.kr');
     $this->assertSame('', $uri->getScheme());
     // Implementations MUST support the schemes "http" and "https" case
     // insensitively, and MAY accommodate other schemes if required. (@withScheme)
     try {
         new Uri('ftp://blog.wani.kr');
         $this->fail();
     } catch (InvalidArgumentexception $e) {
         $this->assertEquals('Unsupported scheme "ftp".', $e->getMessage());
     }
 }
Exemple #2
0
 public function testGetScheme()
 {
     $uri = new Uri('http://blog.wani.kr');
     static::assertSame('http', $uri->getScheme());
     $uri = new Uri('https://blog.wani.kr');
     static::assertSame('https', $uri->getScheme());
     // If no scheme is present, this method MUST return an empty string.
     $uri = new Uri('//blog.wani.kr');
     static::assertSame('', $uri->getScheme());
     $uri = new Uri('blog.wani.kr');
     static::assertSame('', $uri->getScheme());
     // The value returned MUST be normalized to lowercase, per RFC 3986
     // Section 3.1.
     $uri = new Uri('HTTP://blog.wani.kr');
     static::assertSame('http', $uri->getScheme());
     // The trailing ":" character is not part of the scheme and MUST NOT be
     // added.
     $uri = new Uri('://blog.wani.kr');
     static::assertSame('', $uri->getScheme());
     // Implementations MUST support the schemes "http" and "https" case
     // insensitively, and MAY accommodate other schemes if required. (@withScheme)
     new Uri('hello-world://blog.wani.kr');
 }