public function testUserInfoAccessors() { $url = new \r8\URL(); $this->assertFalse($url->userInfoExists()); $this->assertNull($url->getUserInfo()); $url->setPassword("pword"); $this->assertFalse($url->userInfoExists()); $this->assertNull($url->getUserInfo()); $url->setUserName("uname"); $this->assertTrue($url->userInfoExists()); $this->assertSame("uname:pword", $url->getUserInfo()); $this->assertSame($url, $url->setUserInfo("user%20name:pass%2Dword")); $this->assertTrue($url->usernameExists()); $this->assertTrue($url->passwordExists()); $this->assertTrue($url->userInfoExists()); $this->assertSame("user name", $url->getUsername()); $this->assertSame("pass-word", $url->getPassword()); $this->assertSame("user+name:pass-word", $url->getUserInfo()); $this->assertSame($url, $url->setUserInfo("uname:pword@example.com")); $this->assertTrue($url->usernameExists()); $this->assertTrue($url->passwordExists()); $this->assertTrue($url->userInfoExists()); $this->assertSame("uname", $url->getUsername()); $this->assertSame("pword", $url->getPassword()); $this->assertSame("uname:pword", $url->getUserInfo()); $this->assertSame($url, $url->setUserInfo("uname")); $this->assertTrue($url->usernameExists()); $this->assertFalse($url->passwordExists()); $this->assertTrue($url->userInfoExists()); $this->assertSame("uname", $url->getUsername()); $this->assertSame("uname", $url->getUserInfo()); $this->assertSame($url, $url->clearUserInfo()); $this->assertFalse($url->usernameExists()); $this->assertFalse($url->passwordExists()); $this->assertFalse($url->userInfoExists()); $this->assertNull($url->getUserInfo()); }