diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 3de392e025..ddee83b5f1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -466,6 +466,7 @@ phutil_register_library_map(array( 'DifferentialBlockHeraldAction' => 'applications/differential/herald/DifferentialBlockHeraldAction.php', 'DifferentialBlockingReviewerDatasource' => 'applications/differential/typeahead/DifferentialBlockingReviewerDatasource.php', 'DifferentialBranchField' => 'applications/differential/customfield/DifferentialBranchField.php', + 'DifferentialBranchFieldTestCase' => 'applications/differential/customfield/__tests__/DifferentialBranchFieldTestCase.php', 'DifferentialBuildableEngine' => 'applications/differential/harbormaster/DifferentialBuildableEngine.php', 'DifferentialChangeDetailMailView' => 'applications/differential/mail/DifferentialChangeDetailMailView.php', 'DifferentialChangeHeraldFieldGroup' => 'applications/differential/herald/DifferentialChangeHeraldFieldGroup.php', @@ -6472,6 +6473,7 @@ phutil_register_library_map(array( 'DifferentialBlockHeraldAction' => 'HeraldAction', 'DifferentialBlockingReviewerDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'DifferentialBranchField' => 'DifferentialCustomField', + 'DifferentialBranchFieldTestCase' => 'PhabricatorTestCase', 'DifferentialBuildableEngine' => 'HarbormasterBuildableEngine', 'DifferentialChangeDetailMailView' => 'DifferentialMailView', 'DifferentialChangeHeraldFieldGroup' => 'HeraldFieldGroup', diff --git a/src/applications/differential/customfield/DifferentialBranchField.php b/src/applications/differential/customfield/DifferentialBranchField.php index 60291b6be3..9d5d8f81a9 100644 --- a/src/applications/differential/customfield/DifferentialBranchField.php +++ b/src/applications/differential/customfield/DifferentialBranchField.php @@ -45,7 +45,7 @@ final class DifferentialBranchField return pht('%s (bookmark)', $bookmark); } else if (strlen($branch)) { $onto = $diff->loadTargetBranch(); - if (strlen($onto) && ($onto !== $branch)) { + if (phutil_nonempty_string($onto) && ($onto !== $branch)) { return pht( '%s (branched from %s)', $branch, diff --git a/src/applications/differential/customfield/__tests__/DifferentialBranchFieldTestCase.php b/src/applications/differential/customfield/__tests__/DifferentialBranchFieldTestCase.php new file mode 100644 index 0000000000..e96b4bd245 --- /dev/null +++ b/src/applications/differential/customfield/__tests__/DifferentialBranchFieldTestCase.php @@ -0,0 +1,39 @@ + true, + ); + } + + private function getTestDiff() { + $parser = new ArcanistDiffParser(); + $raw_diff = <<parseDiff($raw_diff)); + } + + public function testRenderDiffPropertyViewValue() { + $test_object = new DifferentialBranchField(); + $diff = $this->getTestDiff(); + $diff->setBranch('test'); + $this->assertEqual('test', + $test_object->renderDiffPropertyViewValue($diff)); + } +}