diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -713,6 +713,7 @@ 'DifferentialTabReplacementTestCase' => 'applications/differential/parser/__tests__/DifferentialTabReplacementTestCase.php', 'DifferentialTagsCommitMessageField' => 'applications/differential/field/DifferentialTagsCommitMessageField.php', 'DifferentialTasksCommitMessageField' => 'applications/differential/field/DifferentialTasksCommitMessageField.php', + 'DifferentialTestCommitMessageField' => 'applications/differential/field/DifferentialTestCommitMessageField.php', 'DifferentialTestPlanCommitMessageField' => 'applications/differential/field/DifferentialTestPlanCommitMessageField.php', 'DifferentialTestPlanField' => 'applications/differential/customfield/DifferentialTestPlanField.php', 'DifferentialTitleCommitMessageField' => 'applications/differential/field/DifferentialTitleCommitMessageField.php', @@ -6756,6 +6757,7 @@ 'DifferentialTabReplacementTestCase' => 'PhabricatorTestCase', 'DifferentialTagsCommitMessageField' => 'DifferentialCommitMessageField', 'DifferentialTasksCommitMessageField' => 'DifferentialCommitMessageField', + 'DifferentialTestCommitMessageField' => 'DifferentialCommitMessageField', 'DifferentialTestPlanCommitMessageField' => 'DifferentialCommitMessageField', 'DifferentialTestPlanField' => 'DifferentialCoreCustomField', 'DifferentialTitleCommitMessageField' => 'DifferentialCommitMessageField', diff --git a/src/applications/differential/field/DifferentialCommitMessageField.php b/src/applications/differential/field/DifferentialCommitMessageField.php --- a/src/applications/differential/field/DifferentialCommitMessageField.php +++ b/src/applications/differential/field/DifferentialCommitMessageField.php @@ -60,7 +60,7 @@ } public function renderFieldValue($value) { - if (!strlen($value)) { + if (!phutil_nonempty_string($value)) { return null; } diff --git a/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php b/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php --- a/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php +++ b/src/applications/differential/field/DifferentialRevisionIDCommitMessageField.php @@ -72,7 +72,7 @@ } public function renderFieldValue($value) { - if (!strlen($value)) { + if (!phutil_nonempty_string($value)) { return null; } diff --git a/src/applications/differential/field/DifferentialTestCommitMessageField.php b/src/applications/differential/field/DifferentialTestCommitMessageField.php new file mode 100644 --- /dev/null +++ b/src/applications/differential/field/DifferentialTestCommitMessageField.php @@ -0,0 +1,10 @@ +assertEqual('foo', $test_object->renderFieldValue('foo'), + 'Normal strings should be rendered unaltered'); + + $this->assertEqual(null, $test_object->renderFieldValue(''), + 'Empty strings should be returned as null'); + + $this->assertEqual(null, $test_object->renderFieldValue(null), + 'null values strings should be returned as null'); + + $test_object = new DifferentialRevisionIDCommitMessageField(); + $expected = 'http://phabricator.example.com/D123'; + $this->assertEqual($expected, $test_object->renderFieldValue('123')); + $this->assertEqual(null, $test_object->renderFieldValue(null)); + } + }