Differential D21792 Diff 51949 src/applications/owners/storage/__tests__/PhabricatorOwnersPackageTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/storage/__tests__/PhabricatorOwnersPackageTestCase.php
<?php | <?php | ||||
final class PhabricatorOwnersPackageTestCase extends PhabricatorTestCase { | final class PhabricatorOwnersPackageTestCase extends PhabricatorTestCase { | ||||
public function testFindLongestPathsPerPackage() { | public function testFindLongestPathsPerPackage() { | ||||
$rows = array( | $rows = array( | ||||
array( | array( | ||||
'id' => 1, | 'id' => 1, | ||||
'excluded' => 0, | 'excluded' => 0, | ||||
'dominion' => PhabricatorOwnersPackage::DOMINION_STRONG, | 'dominion' => PhabricatorOwnersPackage::DOMINION_STRONG, | ||||
'path' => 'src/', | 'path' => 'src/', | ||||
), | ), | ||||
array( | array( | ||||
'id' => 1, | 'id' => 1, | ||||
'excluded' => 1, | 'excluded' => 1, | ||||
'dominion' => PhabricatorOwnersPackage::DOMINION_STRONG, | 'dominion' => PhabricatorOwnersPackage::DOMINION_STRONG, | ||||
'path' => 'src/releeph/', | 'path' => 'src/example/', | ||||
), | ), | ||||
array( | array( | ||||
'id' => 2, | 'id' => 2, | ||||
'excluded' => 0, | 'excluded' => 0, | ||||
'dominion' => PhabricatorOwnersPackage::DOMINION_STRONG, | 'dominion' => PhabricatorOwnersPackage::DOMINION_STRONG, | ||||
'path' => 'src/releeph/', | 'path' => 'src/example/', | ||||
), | ), | ||||
); | ); | ||||
$paths = array( | $paths = array( | ||||
'src/' => array('src/a.php' => true, 'src/releeph/b.php' => true), | 'src/' => array('src/a.php' => true, 'src/example/b.php' => true), | ||||
'src/releeph/' => array('src/releeph/b.php' => true), | 'src/example/' => array('src/example/b.php' => true), | ||||
); | ); | ||||
$this->assertEqual( | $this->assertEqual( | ||||
array( | array( | ||||
1 => strlen('src/'), | 1 => strlen('src/'), | ||||
2 => strlen('src/releeph/'), | 2 => strlen('src/example/'), | ||||
), | ), | ||||
PhabricatorOwnersPackage::findLongestPathsPerPackage($rows, $paths)); | PhabricatorOwnersPackage::findLongestPathsPerPackage($rows, $paths)); | ||||
$paths = array( | $paths = array( | ||||
'src/' => array('src/releeph/b.php' => true), | 'src/' => array('src/example/b.php' => true), | ||||
'src/releeph/' => array('src/releeph/b.php' => true), | 'src/example/' => array('src/example/b.php' => true), | ||||
); | ); | ||||
$this->assertEqual( | $this->assertEqual( | ||||
array( | array( | ||||
2 => strlen('src/releeph/'), | 2 => strlen('src/example/'), | ||||
), | ), | ||||
PhabricatorOwnersPackage::findLongestPathsPerPackage($rows, $paths)); | PhabricatorOwnersPackage::findLongestPathsPerPackage($rows, $paths)); | ||||
// Test packages with weak dominion. Here, only package #2 should own the | // Test packages with weak dominion. Here, only package #2 should own the | ||||
// path. Package #1's claim is ceded to Package #2 because it uses weak | // path. Package #1's claim is ceded to Package #2 because it uses weak | ||||
// rules. Package #2 gets the claim even though it also has weak rules | // rules. Package #2 gets the claim even though it also has weak rules | ||||
// because there is no more-specific package. | // because there is no more-specific package. | ||||
▲ Show 20 Lines • Show All 142 Lines • Show Last 20 Lines |