Differential D17058 Diff 41038 src/applications/differential/parser/__tests__/DifferentialCommitMessageParserTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/parser/__tests__/DifferentialCommitMessageParserTestCase.php
| Show All 35 Lines | foreach ($list as $file) { | ||||
| $result_output = $parser->parseCorpus($message); | $result_output = $parser->parseCorpus($message); | ||||
| $result_errors = $parser->getErrors(); | $result_errors = $parser->getErrors(); | ||||
| $this->assertEqual($output, $result_output); | $this->assertEqual($output, $result_output); | ||||
| $this->assertEqual($errors, $result_errors); | $this->assertEqual($errors, $result_errors); | ||||
| } | } | ||||
| } | } | ||||
| public function testDifferentialCommitMessageFieldParser() { | |||||
| $message = <<<EOMESSAGE | |||||
| This is the title. | |||||
| Summary: This is the summary. | |||||
| EOMESSAGE; | |||||
| $fields = array( | |||||
| new DifferentialTitleCommitMessageField(), | |||||
| new DifferentialSummaryCommitMessageField(), | |||||
| ); | |||||
| $expect = array( | |||||
| DifferentialTitleCommitMessageField::FIELDKEY => | |||||
| 'This is the title.', | |||||
| DifferentialSummaryCommitMessageField::FIELDKEY => | |||||
| 'This is the summary.', | |||||
| ); | |||||
| $parser = id(new DifferentialCommitMessageParser()) | |||||
| ->setCommitMessageFields($fields) | |||||
| ->setTitleKey(DifferentialTitleCommitMessageField::FIELDKEY) | |||||
| ->setSummaryKey(DifferentialSummaryCommitMessageField::FIELDKEY); | |||||
| $actual = $parser->parseFields($message); | |||||
| $this->assertEqual($expect, $actual); | |||||
| } | |||||
| public function testDifferentialCommitMessageParserNormalization() { | public function testDifferentialCommitMessageParserNormalization() { | ||||
| $map = array( | $map = array( | ||||
| 'Test Plan' => 'test plan', | 'Test Plan' => 'test plan', | ||||
| 'REVIEWERS' => 'reviewers', | 'REVIEWERS' => 'reviewers', | ||||
| 'sUmmArY' => 'summary', | 'sUmmArY' => 'summary', | ||||
| ); | ); | ||||
| foreach ($map as $input => $expect) { | foreach ($map as $input => $expect) { | ||||
| $this->assertEqual( | $this->assertEqual( | ||||
| $expect, | $expect, | ||||
| DifferentialCommitMessageParser::normalizeFieldLabel($input), | DifferentialCommitMessageParser::normalizeFieldLabel($input), | ||||
| pht('Field normalization of label "%s".', $input)); | pht('Field normalization of label "%s".', $input)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||