Beispiel #1
0
 public function testGetPath()
 {
     $aUrlComponents = array('scheme' => '', 'host' => '', 'user' => '', 'pass' => '', 'path' => __FILE__, 'query' => array(), 'fragment' => '');
     $sUrl = UrlParserA_underTest::makeUrl($aUrlComponents);
     $oUrl = new UrlParserA_underTest($sUrl);
     $this->assertEquals(__FILE__, $oUrl->getPath());
 }
Beispiel #2
0
 public function testEmpty__toString()
 {
     $sUrl = 'http://localhost';
     $o = new UrlParserA_underTest($sUrl);
     $this->assertEquals($sUrl, $o->__toString());
     $this->assertEquals($sUrl, (string) $o);
     $sUrl = 'http://192.168.1.1';
     $o = new UrlParserA_underTest($sUrl);
     $this->assertEquals($sUrl, $o->__toString());
     $this->assertEquals($sUrl, (string) $o);
     //		$sUrl = '//localhost';
     //		$o = new UrlParserA_underTest($sUrl);
     //		$this->assertEquals($sUrl, $o->__toString());
     //		$this->assertEquals($sUrl, (string)$o);
     //		$sUrl = '//192.168.1.1';
     //		$o = new UrlParserA_underTest($sUrl);
     //		$this->assertEquals($sUrl, $o->__toString());
     //		$this->assertEquals($sUrl, (string)$o);
     //		$sUrl = 'localhost';
     //		$o = new UrlParserA_underTest($sUrl);
     //		$this->assertEquals($sUrl, $o->__toString());
     //		$this->assertEquals($sUrl, (string)$o);
     //		$sUrl = '192.168.1.1';
     //		$o = new UrlParserA_underTest($sUrl);
     //		$this->assertEquals($sUrl, $o->__toString());
     //		$this->assertEquals($sUrl, (string)$o);
 }
Beispiel #3
0
 public function testGetPort()
 {
     $sPort = 8080;
     $aUrlComponents = array('scheme' => 'http', 'host' => 'localhost:' . $sPort, 'user' => '', 'pass' => '', 'path' => '', 'query' => array(), 'fragment' => '');
     $sUrl = UrlParserA_underTest::makeUrl($aUrlComponents);
     $oUrl = new UrlParserA_underTest($sUrl);
     $this->assertEquals($sPort, $oUrl->getPort());
 }
Beispiel #4
0
 public function testAddRelativePathWithCurrentDirectory()
 {
     $sLocalHost = 'http://localhost';
     $sStr = 'ana/./are/mere';
     $oUrl = new UrlParserA_underTest($sLocalHost);
     $oUrl->addPath($sStr);
     $sCurrentStr = str_replace('./', '', $sStr);
     $this->assertEquals($sLocalHost . '/' . $sCurrentStr, $oUrl->getCompleteUri(true));
 }
Beispiel #5
0
 public function testHasSchemeFalse()
 {
     //$this->markTestSkipped('Need to implement hasScheme vs. displayScheme');
     $oUrl = new UrlParserA_underTest('//localhost');
     $this->assertFalse($oUrl->hasScheme());
     $oUrl = new UrlParserA_underTest(__FILE__);
     $this->assertFalse($oUrl->hasScheme());
     $oUrl = new UrlParserA_underTest('192.168.1.254');
     $this->assertFalse($oUrl->hasScheme());
 }
Beispiel #6
0
 /**
  * @covers \vsc\infrastructure\urls\UrlParserA::getTldOf
  */
 public function testGetTldOf()
 {
     $sHost = 'example.com';
     $sTld = substr($sHost, strrpos($sHost, '.') + 1);
     $this->assertEquals($sTld, UrlParserA_underTest::getTldOf($sHost));
     $sHost = 'localhost';
     $this->assertEquals($sHost, UrlParserA_underTest::getTldOf($sHost));
     $sIp = '192.168.1.1';
     $this->assertFalse(UrlParserA_underTest::getTldOf($sIp));
     $sEmpty = '';
     $this->assertFalse(UrlParserA_underTest::getTldOf($sEmpty));
     $sNull = null;
     $this->assertFalse(UrlParserA_underTest::getTldOf($sNull));
 }
Beispiel #7
0
 /**
  * @FIXME - this test, and the method are faulty at a first glance
  */
 public function testGetParentPathWithRelativePath()
 {
     $sUrl = '/test/ana/../../rest/application/./processors/RESTProcessorA/validContentTypeTest.php';
     $oUrl = new UrlParserA_underTest($sUrl);
     $this->assertEquals('/rest/application', $oUrl->getParentPath(3));
 }
Beispiel #8
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/'));
 }
 public function testUrlNoSchemePath()
 {
     $oUrl = new UrlParserA_underTest('//localhost');
     $this->assertEquals($oUrl->getCompleteUri(true), $oUrl->getCompleteParentUri(true));
 }
Beispiel #10
0
 public function testSetRealPath()
 {
     $o = new UrlParserA_underTest();
     $o->setPath(__FILE__);
     $this->assertEquals(__FILE__, $o->getPath());
 }