Generate file attachment transactions for explicit Remarkup attachments on common...
[phabricator.git] / src / applications / differential / xaction / DifferentialRevisionTestPlanTransaction.php
blob99837a09fa8ebdeb2c01d1bd086c551d54fc4655
1 <?php
3 final class DifferentialRevisionTestPlanTransaction
4 extends DifferentialRevisionTransactionType {
6 const TRANSACTIONTYPE = 'differential.revision.testplan';
7 const EDITKEY = 'testPlan';
9 public function generateOldValue($object) {
10 return $object->getTestPlan();
13 public function applyInternalEffects($object, $value) {
14 $object->setTestPlan($value);
17 public function getTitle() {
18 return pht(
19 '%s edited the test plan for this revision.',
20 $this->renderAuthor());
23 public function getTitleForFeed() {
24 return pht(
25 '%s updated the test plan for %s.',
26 $this->renderAuthor(),
27 $this->renderObject());
30 public function hasChangeDetailView() {
31 return true;
34 public function getMailDiffSectionHeader() {
35 return pht('CHANGES TO TEST PLAN');
38 public function newChangeDetailView() {
39 $viewer = $this->getViewer();
41 return id(new PhabricatorApplicationTransactionTextDiffDetailView())
42 ->setViewer($viewer)
43 ->setOldText($this->getOldValue())
44 ->setNewText($this->getNewValue());
47 public function newRemarkupChanges() {
48 $changes = array();
50 $changes[] = $this->newRemarkupChange()
51 ->setOldValue($this->getOldValue())
52 ->setNewValue($this->getNewValue());
54 return $changes;
57 public function validateTransactions($object, array $xactions) {
58 $errors = $this->validateCommitMessageCorpusTransactions(
59 $object,
60 $xactions,
61 pht('Test Plan'));
63 $is_required = PhabricatorEnv::getEnvConfig(
64 'differential.require-test-plan-field');
66 if ($is_required) {
67 if ($this->isEmptyTextTransaction($object->getTestPlan(), $xactions)) {
68 $errors[] = $this->newRequiredError(
69 pht(
70 'You must provide a test plan. Describe the actions you '.
71 'performed to verify the behavior of this change.'));
75 return $errors;
78 public function getTransactionTypeForConduit($xaction) {
79 return 'testPlan';
82 public function getFieldValuesForConduit($xaction, $data) {
83 return array(
84 'old' => $xaction->getOldValue(),
85 'new' => $xaction->getNewValue(),