[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorRepositoryTestCase 4 extends PhabricatorTestCase { 5 6 public function testRepositoryURIProtocols() { 7 $tests = array( 8 '/path/to/repo' => 'file', 9 'file:///path/to/repo' => 'file', 10 'ssh://[email protected]/path' => 'ssh', 11 '[email protected]:path' => 'ssh', 12 'git://[email protected]/path' => 'git', 13 'svn+ssh://example.com/path' => 'svn+ssh', 14 'https://example.com/repo/' => 'https', 15 'http://example.com/' => 'http', 16 'https://[email protected]/' => 'https', 17 ); 18 19 foreach ($tests as $uri => $expect) { 20 $repository = new PhabricatorRepository(); 21 $repository->setDetail('remote-uri', $uri); 22 23 $this->assertEqual( 24 $expect, 25 $repository->getRemoteProtocol(), 26 "Protocol for '{$uri}'."); 27 } 28 } 29 30 public function testBranchFilter() { 31 $git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT; 32 33 $repo = new PhabricatorRepository(); 34 $repo->setVersionControlSystem($git); 35 36 $this->assertTrue( 37 $repo->shouldTrackBranch('imaginary'), 38 'Track all branches by default.'); 39 40 $repo->setDetail( 41 'branch-filter', 42 array( 43 'master' => true, 44 )); 45 46 $this->assertTrue( 47 $repo->shouldTrackBranch('master'), 48 'Track listed branches.'); 49 50 $this->assertFalse( 51 $repo->shouldTrackBranch('imaginary'), 52 'Do not track unlisted branches.'); 53 } 54 55 public function testSubversionPathInfo() { 56 $svn = PhabricatorRepositoryType::REPOSITORY_TYPE_SVN; 57 58 $repo = new PhabricatorRepository(); 59 $repo->setVersionControlSystem($svn); 60 61 $repo->setDetail('remote-uri', 'http://svn.example.com/repo'); 62 $this->assertEqual( 63 'http://svn.example.com/repo', 64 $repo->getSubversionPathURI()); 65 66 $repo->setDetail('remote-uri', 'http://svn.example.com/repo/'); 67 $this->assertEqual( 68 'http://svn.example.com/repo', 69 $repo->getSubversionPathURI()); 70 71 $repo->setDetail('hosting-enabled', true); 72 73 $repo->setDetail('local-path', '/var/repo/SVN'); 74 $this->assertEqual( 75 'file:///var/repo/SVN', 76 $repo->getSubversionPathURI()); 77 78 $repo->setDetail('local-path', '/var/repo/SVN/'); 79 $this->assertEqual( 80 'file:///var/repo/SVN', 81 $repo->getSubversionPathURI()); 82 83 $this->assertEqual( 84 'file:///var/repo/SVN/a@', 85 $repo->getSubversionPathURI('a')); 86 87 $this->assertEqual( 88 'file:///var/repo/SVN/a@1', 89 $repo->getSubversionPathURI('a', 1)); 90 91 $this->assertEqual( 92 'file:///var/repo/SVN/%3F@22', 93 $repo->getSubversionPathURI('?', 22)); 94 95 $repo->setDetail('svn-subpath', 'quack/trunk/'); 96 97 $this->assertEqual( 98 'file:///var/repo/SVN/quack/trunk/@', 99 $repo->getSubversionBaseURI()); 100 101 $this->assertEqual( 102 'file:///var/repo/SVN/quack/trunk/@HEAD', 103 $repo->getSubversionBaseURI('HEAD')); 104 105 } 106 107 public function testFilterMercurialDebugOutput() { 108 $map = array( 109 '' => '', 110 111 "quack\n" => "quack\n", 112 113 "ignoring untrusted configuration option x.y = z\nquack\n" => 114 "quack\n", 115 116 "ignoring untrusted configuration option x.y = z\n". 117 "ignoring untrusted configuration option x.y = z\n". 118 "quack\n" => 119 "quack\n", 120 121 "ignoring untrusted configuration option x.y = z\n". 122 "ignoring untrusted configuration option x.y = z\n". 123 "ignoring untrusted configuration option x.y = z\n". 124 "quack\n" => 125 "quack\n", 126 127 "quack\n". 128 "ignoring untrusted configuration option x.y = z\n". 129 "ignoring untrusted configuration option x.y = z\n". 130 "ignoring untrusted configuration option x.y = z\n" => 131 "quack\n", 132 133 "ignoring untrusted configuration option x.y = z\n". 134 "ignoring untrusted configuration option x.y = z\n". 135 "duck\n". 136 "ignoring untrusted configuration option x.y = z\n". 137 "ignoring untrusted configuration option x.y = z\n". 138 "bread\n". 139 "ignoring untrusted configuration option x.y = z\n". 140 "quack\n" => 141 "duck\nbread\nquack\n", 142 143 "ignoring untrusted configuration option x.y = z\n". 144 "duckignoring untrusted configuration option x.y = z\n". 145 "quack" => 146 'duckquack', 147 ); 148 149 foreach ($map as $input => $expect) { 150 $actual = PhabricatorRepository::filterMercurialDebugOutput($input); 151 $this->assertEqual($expect, $actual, $input); 152 } 153 } 154 155 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |