Page MenuHomePhorge

D25086.1734698989.diff
No OneTemporary

D25086.1734698989.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -5843,6 +5843,7 @@
'PonderQuestionSearchEngine' => 'applications/ponder/query/PonderQuestionSearchEngine.php',
'PonderQuestionStatus' => 'applications/ponder/constants/PonderQuestionStatus.php',
'PonderQuestionStatusController' => 'applications/ponder/controller/PonderQuestionStatusController.php',
+ 'PonderQuestionStatusTestCase' => 'applications/ponder/storage/__tests__/PonderQuestionStatusTestCase.php',
'PonderQuestionStatusTransaction' => 'applications/ponder/xaction/PonderQuestionStatusTransaction.php',
'PonderQuestionTitleTransaction' => 'applications/ponder/xaction/PonderQuestionTitleTransaction.php',
'PonderQuestionTransaction' => 'applications/ponder/storage/PonderQuestionTransaction.php',
@@ -12757,6 +12758,7 @@
'PonderQuestionSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PonderQuestionStatus' => 'PonderConstants',
'PonderQuestionStatusController' => 'PonderController',
+ 'PonderQuestionStatusTestCase' => 'PhutilTestCase',
'PonderQuestionStatusTransaction' => 'PonderQuestionTransactionType',
'PonderQuestionTitleTransaction' => 'PonderQuestionTransactionType',
'PonderQuestionTransaction' => 'PhabricatorModularTransaction',
diff --git a/src/applications/ponder/constants/PonderQuestionStatus.php b/src/applications/ponder/constants/PonderQuestionStatus.php
--- a/src/applications/ponder/constants/PonderQuestionStatus.php
+++ b/src/applications/ponder/constants/PonderQuestionStatus.php
@@ -86,4 +86,14 @@
);
}
+ /**
+ * Check whenever a Ponder question status is Closed
+ *
+ * @param $status string
+ * @return bool
+ */
+ public static function isQuestionStatusClosed($status) {
+ return in_array($status, self::getQuestionStatusClosedMap(), true);
+ }
+
}
diff --git a/src/applications/ponder/query/PonderQuestionSearchEngine.php b/src/applications/ponder/query/PonderQuestionSearchEngine.php
--- a/src/applications/ponder/query/PonderQuestionSearchEngine.php
+++ b/src/applications/ponder/query/PonderQuestionSearchEngine.php
@@ -157,6 +157,9 @@
'Asked by %s',
$handles[$question->getAuthorPHID()]->renderLink()));
+ // Render Closed Questions as striked in query results
+ $item->setDisabled($question->isStatusClosed());
+
$item->addAttribute(
pht(
'%s Answer(s)',
diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php
--- a/src/applications/ponder/storage/PonderQuestion.php
+++ b/src/applications/ponder/storage/PonderQuestion.php
@@ -137,6 +137,14 @@
return self::MARKUP_FIELD_CONTENT;
}
+ /**
+ * Check whenever this Question has whatever closed status
+ *
+ * @return bool
+ */
+ public function isStatusClosed() {
+ return PonderQuestionStatus::isQuestionStatusClosed($this->status);
+ }
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
diff --git a/src/applications/ponder/storage/__tests__/PonderQuestionStatusTestCase.php b/src/applications/ponder/storage/__tests__/PonderQuestionStatusTestCase.php
new file mode 100644
--- /dev/null
+++ b/src/applications/ponder/storage/__tests__/PonderQuestionStatusTestCase.php
@@ -0,0 +1,25 @@
+<?php
+
+final class PonderQuestionStatusTestCase extends PhutilTestCase {
+
+ public function testClosedStatuses() {
+
+ $statuses = PonderQuestionStatus::getQuestionStatusClosedMap();
+ foreach ($statuses as $status) {
+ $question = new PonderQuestion();
+ $question->setStatus($status);
+ $this->assertEqual(true, $question->isStatusClosed());
+ }
+
+ }
+
+ public function testOpenedStatuses() {
+ $statuses = PonderQuestionStatus::getQuestionStatusOpenMap();
+ foreach ($statuses as $status) {
+ $question = new PonderQuestion();
+ $question->setStatus($status);
+ $this->assertEqual(false, $question->isStatusClosed());
+ }
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 12:49 (18 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1018282
Default Alt Text
D25086.1734698989.diff (4 KB)

Event Timeline