Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / almanac / util / __tests__ / AlmanacNamesTestCase.php
blob8c3754ac237792540650e42036b9a3b15ae5b139
1 <?php
3 final class AlmanacNamesTestCase extends PhabricatorTestCase {
5 public function testServiceOrDeviceNames() {
6 $map = array(
7 '' => false,
8 'a' => false,
9 'ab' => false,
10 '...' => false,
11 'ab.' => false,
12 '.ab' => false,
13 'A-B' => false,
14 'A!B' => false,
15 'A.B' => false,
16 'a..b' => false,
17 '1.2' => false,
18 '127.0.0.1' => false,
19 '1.b' => false,
20 'a.1' => false,
21 'a.1.b' => false,
22 '-.a' => false,
23 '-a.b' => false,
24 'a-.b' => false,
25 'a.-' => false,
26 'a.-b' => false,
27 'a.b-' => false,
28 '-.-' => false,
29 'a--b' => false,
31 'abc' => true,
32 'a.b' => true,
33 'db.companyname.instance' => true,
34 'web002.useast.example.com' => true,
35 'master.example-corp.com' => true,
37 // Maximum length is 100.
38 str_repeat('a', 100) => true,
39 str_repeat('a', 101) => false,
42 foreach ($map as $input => $expect) {
43 $caught = null;
44 try {
45 AlmanacNames::validateName($input);
46 } catch (Exception $ex) {
47 $caught = $ex;
49 $this->assertEqual(
50 $expect,
51 !($caught instanceof Exception),
52 $input);