Beispiel #1
0
 public function testBasicSetPath()
 {
     $value = uniqid('test:');
     $url = new Url();
     $url->setPath($value);
     $this->assertEquals($value, $url->getPath());
 }
Beispiel #2
0
 public function testBasicSetScheme()
 {
     $value = 'https';
     $url = new Url();
     $url->setScheme($value);
     $this->assertEquals($value, $url->getScheme());
 }
Beispiel #3
0
 public function testGetQuery()
 {
     $value = ['ana' => 'mere'];
     $oUrl = new Url();
     $oUrl->setQuery($value);
     $this->assertEquals($value, $oUrl->getQuery());
 }
 public function testGetQueryString()
 {
     $value = ['ana' => 'mere', 'test' => 123];
     $oUrl = new Url();
     $oUrl->setQuery($value);
     $this->assertEquals('ana=mere&test=123', $oUrl->getRawQueryString());
 }
Beispiel #5
0
 public function testBasicSetQuery()
 {
     $value = ['ana' => 'mere', 'test' => 123];
     $url = new Url();
     $url->setQuery($value);
     $this->assertEquals($value, $url->getQuery());
 }
Beispiel #6
0
 public function testBasicValidSchemes()
 {
     $mirror = new \ReflectionClass(Url::class);
     $validSchemes = $mirror->getStaticProperties()['validSchemes'];
     foreach ($validSchemes as $scheme) {
         $this->assertTrue(Url::isValidScheme($scheme));
     }
 }
Beispiel #7
0
 public function testInstantiationIsNull()
 {
     $url = new Url();
     $this->assertNull($url->getHost());
 }
Beispiel #8
0
 public function testFalseAtInstantiation()
 {
     $url = new Url();
     $this->assertFalse($url->hasHost());
 }
Beispiel #9
0
 public function changeSubdomain($sNewSubdomain)
 {
     $this->oUrl->setHost(str_ireplace($this->getSubdomain(), $sNewSubdomain, $this->oUrl->getHost()));
     return $this->oUrl->getHost();
 }
Beispiel #10
0
 /**
  * @test
  */
 public function parse_urlIPWithoutProtocol()
 {
     $aUrlComponents = array('scheme' => 'http', 'host' => '127.0.0.1', 'user' => '', 'pass' => '', 'path' => '/', 'query' => [], 'fragment' => '');
     $oUrl = new Url();
     $oUrl->setScheme($aUrlComponents['scheme']);
     $oUrl->setHost($aUrlComponents['host']);
     $oUrl->setPath($aUrlComponents['path']);
     $oUrl->setQuery($aUrlComponents['query']);
     $oUrl->setFragment($aUrlComponents['fragment']);
     $this->assertEquals($oUrl, UrlParserA_underTest::parse_url('//127.0.0.1/'));
 }
Beispiel #11
0
 /**
  * @returns Url
  */
 public function getUrl()
 {
     $sRegex = '#(' . str_replace('#', '\\#', $this->getRegex()) . ')#iUu';
     $bHaveMatch = preg_match($sRegex, $this->sMatchingUrl, $aMatches);
     if ($bHaveMatch) {
         $url = new Url();
         $url->setPath($aMatches[0]);
         return $url;
     } else {
         return new Base();
     }
 }
Beispiel #12
0
 /**
  * @return Url
  */
 public function getUriObject()
 {
     if (!Url::isValid($this->oUri)) {
         $this->oUri = UrlParserA::url($this->getUri());
     }
     return $this->oUri;
 }
Beispiel #13
0
 public function getUrl()
 {
     return parent::getUrl();
 }
Beispiel #14
0
 public function testIsRemoteIP()
 {
     $oUrl = new Url();
     $oUrl->setHost('8.8.8.8');
     $this->assertFalse($oUrl->isLocal());
 }
Beispiel #15
0
 public function testInstantiationIsNull()
 {
     $url = new Url();
     $this->assertEquals('', $url->getPath());
 }