Differential D17502 Diff 42112 src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/field/__tests__/DifferentialCommitMessageFieldTestCase.php
| <?php | <?php | ||||
| final class DifferentialCommitMessageFieldTestCase | final class DifferentialCommitMessageFieldTestCase | ||||
| extends PhabricatorTestCase { | extends PhabricatorTestCase { | ||||
| public function testRevisionCommitMessageFieldParsing() { | public function testRevisionCommitMessageFieldParsing() { | ||||
| $base_uri = 'https://www.example.com/'; | $base_uri = 'https://www.example.com/'; | ||||
| $tests = array( | $tests = array( | ||||
| 'D123' => 123, | 'D123' => 123, | ||||
| 'd123' => 123, | 'd123' => 123, | ||||
| " \n d123 \n " => 123, | " \n d123 \n " => 123, | ||||
| "D123\nSome-Custom-Field: The End" => 123, | "D123\nSome-Custom-Field: The End" => 123, | ||||
| "{$base_uri}D123" => 123, | "{$base_uri}D123" => 123, | ||||
| "{$base_uri}D123\nSome-Custom-Field: The End" => 123, | "{$base_uri}D123\nSome-Custom-Field: The End" => 123, | ||||
| 'https://www.other.com/D123' => null, | |||||
| ); | ); | ||||
| $env = PhabricatorEnv::beginScopedEnv(); | $env = PhabricatorEnv::beginScopedEnv(); | ||||
| $env->overrideEnvConfig('phabricator.base-uri', $base_uri); | $env->overrideEnvConfig('phabricator.base-uri', $base_uri); | ||||
| foreach ($tests as $input => $expect) { | foreach ($tests as $input => $expect) { | ||||
| $actual = id(new DifferentialRevisionIDCommitMessageField()) | $actual = id(new DifferentialRevisionIDCommitMessageField()) | ||||
| ->parseFieldValue($input); | ->parseFieldValue($input); | ||||
| $this->assertEqual($expect, $actual, pht('Parse of: %s', $input)); | $this->assertEqual($expect, $actual, pht('Parse of: %s', $input)); | ||||
| } | } | ||||
| unset($env); | unset($env); | ||||
| } | } | ||||
| } | } | ||||