Path: blob/master/src/applications/differential/customfield/DifferentialUnitField.php
12256 views
<?php12final class DifferentialUnitField3extends DifferentialCustomField {45public function getFieldKey() {6return 'differential:unit';7}89public function getFieldName() {10return pht('Unit');11}1213public function getFieldDescription() {14return pht('Shows unit test results.');15}1617public function shouldAppearInPropertyView() {18return true;19}2021public function renderPropertyViewValue(array $handles) {22return null;23}2425public function shouldAppearInDiffPropertyView() {26return true;27}2829public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {30return $this->getFieldName();31}3233public function getWarningsForDetailView() {34$warnings = array();3536$viewer = $this->getViewer();37$diff = $this->getObject()->getActiveDiff();3839$buildable = id(new HarbormasterBuildableQuery())40->setViewer($viewer)41->withBuildablePHIDs(array($diff->getPHID()))42->withManualBuildables(false)43->executeOne();44if ($buildable) {45switch ($buildable->getBuildableStatus()) {46case HarbormasterBuildableStatus::STATUS_BUILDING:47$warnings[] = pht(48'These changes have not finished building yet and may have build '.49'failures.');50break;51case HarbormasterBuildableStatus::STATUS_FAILED:52$warnings[] = pht(53'These changes have failed to build.');54break;55}56}5758$status = $this->getObject()->getActiveDiff()->getUnitStatus();59if ($status < DifferentialUnitStatus::UNIT_WARN) {60// Don't show any warnings.61} else if ($status == DifferentialUnitStatus::UNIT_AUTO_SKIP) {62// Don't show any warnings.63} else if ($status == DifferentialUnitStatus::UNIT_SKIP) {64$warnings[] = pht(65'Unit tests were skipped when generating these changes.');66} else {67$warnings[] = pht('These changes have unit test problems.');68}6970return $warnings;71}7273public function renderDiffPropertyViewValue(DifferentialDiff $diff) {74$status_value = $diff->getUnitStatus();75$status = DifferentialUnitStatus::newStatusFromValue($status_value);7677$status_icon = $status->getIconIcon();78$status_color = $status->getIconColor();79$status_name = $status->getName();8081$status = id(new PHUIStatusListView())82->addItem(83id(new PHUIStatusItemView())84->setIcon($status_icon, $status_color)85->setTarget($status_name));8687return $status;88}8990}919293