assertEquals('https://google.com', $this->addScheme($url)); } public function testNoSchemeAndTrailingSlash() { $url = 'google.com/'; $this->assertEquals('https://google.com', $this->addScheme($url)); } public function testNoSchemeAndTrailingSlashAndHttp() { $url = 'http://google.com/'; $this->assertEquals('https://google.com', $this->addScheme($url)); } private function addScheme($url, $scheme = 'https://') { $url = str_replace('http://', '', $url); $url = parse_url($url, PHP_URL_SCHEME) === null ? $scheme.$url : $url; return rtrim($url, '/'); } }