Page MenuHomePhorge

D25334.1734848345.diff
No OneTemporary

D25334.1734848345.diff

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 @@
+<?php
+
+/**
+ * This class should only be used for unit tests
+ */
+final class DifferentialTestCommitMessageField
+ extends DifferentialCommitMessageField {
+ public function getFieldName() { return 'Test'; }
+ public function getFieldOrder() { return 1; }
+}
diff --git a/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php b/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
--- a/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
+++ b/src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
@@ -28,4 +28,21 @@
unset($env);
}
+ public function testRenderFieldValue() {
+ $test_object = new DifferentialTestCommitMessageField();
+ $this->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));
+ }
+
}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 06:19 (19 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1024192
Default Alt Text
D25334.1734848345.diff (4 KB)

Event Timeline