public function testHostFixDisable()
 {
     //testing hostfix disable
     \akrys\ExtendedParseUrl\HostFixPHP547::disable();
     $ref = new ReflectionProperty('akrys\\ExtendedParseUrl\\HostFixPHP547', 'enabled');
     $ref->setAccessible(true);
     $this->assertFalse($ref->getValue());
     $this->assertFalse(\akrys\ExtendedParseUrl\HostFixPHP547::isEnabled());
 }
Exemple #2
0
 public function testFunctionParseURLWithoutSchemeSpaces()
 {
     //test case URL wihtout scheme
     //there could be some problems with spaces in the beginning. So we have
     //to test if this is working correctly
     $url = new akrys\ExtendedParseUrl\URL(' //example.com/path/to/nothing.php?test/9)4/3 ');
     //As this test can run on PHP < 5.4.7 and PHP >= 5.4.7, both scenarios
     //are correct
     $host = $url->getHost();
     if ($host == '' && !\akrys\ExtendedParseUrl\HostFixPHP547::isEnabled()) {
         //expected behavior in PHP < 5.4.7
         $this->assertEquals('', $host, 'wrong path');
         //6
         $this->assertEquals('//example.com/path/to/nothing.php', $url->getPath(), 'wrong path');
         //6
         $this->assertEquals('//example.com/path/to', $url->getDirname(), 'wrong dirname');
         //9
         $this->assertEquals('nothing.php', $url->getBasename(), 'wrong basename');
         //10
         $this->assertEquals(array('example.com', 'path', 'to', 'nothing.php'), $url->getPathArray(), 'wrong patharray');
         //11
         $this->assertEquals(array(), $url->getHostArray(), 'wrong host array');
         //13
     } else {
         //expected behavior in PHP >= 5.4.7 or with Hostname-Fix enabled
         $this->assertEquals('example.com', $host, 'wrong host');
         //2
         $this->assertEquals('/path/to/nothing.php', $url->getPath(), 'wrong path');
         //6
         $this->assertEquals('/path/to', $url->getDirname(), 'wrong dirname');
         //9
         $this->assertEquals('nothing.php', $url->getBasename(), 'wrong basename');
         //10
         $this->assertEquals(array('path', 'to', 'nothing.php'), $url->getPathArray(), 'wrong patharray');
         //11
         $this->assertEquals(array('example', 'com'), $url->getHostArray(), 'wrong host array');
         //13
     }
     //Components that don't differ
     $this->assertEquals('', $url->getScheme(), 'wrong scheme');
     //1
     $this->assertEquals('', $url->getPort(), 'wrong port');
     //3
     $this->assertEquals('', $url->getUserName(), 'wrong user');
     //4
     $this->assertEquals('', $url->getUserPassword(), 'wrong pass');
     //5
     $this->assertEquals('test/9)4/3', $url->getQuery(), 'wrong query');
     //7
     $this->assertEquals('', $url->getFragment(), 'wrong fragment');
     //8
     $this->assertEquals(array('test/9)4/3' => ''), $url->getParameter(), 'wrong parameter');
     //12
 }