df939f1337
Summary:
Ref T11114. Converting to EditEngine caused us to stop running this validation, since these fields no longer subclass this parent. Restore the validation.
Also, make sure we check the //first// line of the value, too. After the change to make "Tests: xyz" a valid title, you could write silly summaries / test plans and escape the check if the first line was bogus.
Test Plan: {F2493228}
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T11114
Differential Revision: https://secure.phabricator.com/D17248
61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class DifferentialTestPlanCommitMessageField
|
|
extends DifferentialCommitMessageField {
|
|
|
|
const FIELDKEY = 'testPlan';
|
|
|
|
public function getFieldName() {
|
|
return pht('Test Plan');
|
|
}
|
|
|
|
public function getFieldOrder() {
|
|
return 3000;
|
|
}
|
|
|
|
public function getFieldAliases() {
|
|
return array(
|
|
'Testplan',
|
|
'Tested',
|
|
'Tests',
|
|
);
|
|
}
|
|
|
|
public function isFieldEnabled() {
|
|
return $this->isCustomFieldEnabled('differential:test-plan');
|
|
}
|
|
|
|
public function validateFieldValue($value) {
|
|
$is_required = PhabricatorEnv::getEnvConfig(
|
|
'differential.require-test-plan-field');
|
|
|
|
if ($is_required && !strlen($value)) {
|
|
$this->raiseValidationException(
|
|
pht(
|
|
'You must provide a test plan. Describe the actions you performed '.
|
|
'to verify the behavior of this change.'));
|
|
}
|
|
}
|
|
|
|
public function readFieldValueFromObject(DifferentialRevision $revision) {
|
|
return $revision->getTestPlan();
|
|
}
|
|
|
|
public function getFieldTransactions($value) {
|
|
return array(
|
|
array(
|
|
'type' => DifferentialRevisionTestPlanTransaction::EDITKEY,
|
|
'value' => $value,
|
|
),
|
|
);
|
|
}
|
|
|
|
public function validateTransactions($object, array $xactions) {
|
|
return $this->validateCommitMessageCorpusTransactions(
|
|
$object,
|
|
$xactions,
|
|
pht('Test Plan'));
|
|
}
|
|
|
|
}
|