Differential D20872 Diff 49758 src/applications/repository/data/__tests__/PhabricatorRepositoryURINormalizerTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/data/__tests__/PhabricatorRepositoryURINormalizerTestCase.php
Show All 25 Lines | foreach ($cases as $input => $expect) { | ||||
$normal = new PhabricatorRepositoryURINormalizer($type_git, $input); | $normal = new PhabricatorRepositoryURINormalizer($type_git, $input); | ||||
$this->assertEqual( | $this->assertEqual( | ||||
$expect, | $expect, | ||||
$normal->getNormalizedPath(), | $normal->getNormalizedPath(), | ||||
pht('Normalized Git path for "%s".', $input)); | pht('Normalized Git path for "%s".', $input)); | ||||
} | } | ||||
} | } | ||||
public function testDomainURINormalizer() { | |||||
$base_domain = 'base.phabricator.example.com'; | |||||
$ssh_domain = 'ssh.phabricator.example.com'; | |||||
$env = PhabricatorEnv::beginScopedEnv(); | |||||
$env->overrideEnvConfig('phabricator.base-uri', 'http://'.$base_domain); | |||||
$env->overrideEnvConfig('diffusion.ssh-host', $ssh_domain); | |||||
$cases = array( | |||||
'/' => '<void>', | |||||
'/path/to/local/repo.git' => '<void>', | |||||
'ssh://user@domain.com/path.git' => 'domain.com', | |||||
'ssh://user@DOMAIN.COM/path.git' => 'domain.com', | |||||
'http://'.$base_domain.'/diffusion/X/' => '<base-uri>', | |||||
'ssh://'.$ssh_domain.'/diffusion/X/' => '<ssh-host>', | |||||
'git@'.$ssh_domain.':bananas.git' => '<ssh-host>', | |||||
); | |||||
$type_git = PhabricatorRepositoryURINormalizer::TYPE_GIT; | |||||
foreach ($cases as $input => $expect) { | |||||
$normal = new PhabricatorRepositoryURINormalizer($type_git, $input); | |||||
$this->assertEqual( | |||||
$expect, | |||||
$normal->getNormalizedDomain(), | |||||
pht('Normalized domain for "%s".', $input)); | |||||
} | |||||
} | |||||
public function testSVNURINormalizer() { | public function testSVNURINormalizer() { | ||||
$cases = array( | $cases = array( | ||||
'file:///path/to/repo' => 'path/to/repo', | 'file:///path/to/repo' => 'path/to/repo', | ||||
'file:///path/to/repo/' => 'path/to/repo', | 'file:///path/to/repo/' => 'path/to/repo', | ||||
); | ); | ||||
$type_svn = PhabricatorRepositoryURINormalizer::TYPE_SVN; | $type_svn = PhabricatorRepositoryURINormalizer::TYPE_SVN; | ||||
Show All 10 Lines |