Differential D16417 Diff 39574 src/applications/harbormaster/__tests__/HarbormasterConstantsTestCase.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/__tests__/HarbormasterConstantsTestCase.php
- This file was added.
<?php | |||||
final class HarbormasterConstantsTestCase extends PhabricatorTestCase { | |||||
public function testSummarizeLintStatuses() { | |||||
$test_sets = array(); | |||||
$test_sets['empty'] = array( | |||||
'input' => array(), | |||||
'expected' => null, | |||||
); | |||||
$test_sets['simple'] = array( | |||||
'input' => array( | |||||
ArcanistLintSeverity::SEVERITY_ADVICE, | |||||
ArcanistLintSeverity::SEVERITY_WARNING, | |||||
ArcanistLintSeverity::SEVERITY_ERROR, | |||||
), | |||||
'expected' => ArcanistLintSeverity::SEVERITY_ERROR, | |||||
); | |||||
$test_sets['reversed simple'] = array( | |||||
'input' => array( | |||||
ArcanistLintSeverity::SEVERITY_ERROR, | |||||
ArcanistLintSeverity::SEVERITY_WARNING, | |||||
ArcanistLintSeverity::SEVERITY_ADVICE, | |||||
), | |||||
'expected' => ArcanistLintSeverity::SEVERITY_ERROR, | |||||
); | |||||
$test_sets['all advice'] = array( | |||||
'input' => array( | |||||
ArcanistLintSeverity::SEVERITY_ADVICE, | |||||
ArcanistLintSeverity::SEVERITY_ADVICE, | |||||
ArcanistLintSeverity::SEVERITY_ADVICE, | |||||
), | |||||
'expected' => ArcanistLintSeverity::SEVERITY_ADVICE, | |||||
); | |||||
foreach ($test_sets as $key => $set) { | |||||
$input = $set['input']; | |||||
$expected = $set['expected']; | |||||
$result = HarbormasterLintStatus::summarizeStatuses($input); | |||||
$this->assertEqual($expected, $result, 'test case: '.$key); | |||||
} | |||||
} | |||||
public function testSummarizeUnitStatuses() { | |||||
$test_sets = array(); | |||||
$test_sets['empty'] = array( | |||||
'input' => array(), | |||||
'expected' => null, | |||||
); | |||||
$test_sets['simple'] = array( | |||||
'input' => array( | |||||
ArcanistUnitTestResult::RESULT_PASS, | |||||
ArcanistUnitTestResult::RESULT_SKIP, | |||||
ArcanistUnitTestResult::RESULT_FAIL, | |||||
), | |||||
'expected' => ArcanistUnitTestResult::RESULT_FAIL, | |||||
); | |||||
$test_sets['reversed simple'] = array( | |||||
'input' => array( | |||||
ArcanistUnitTestResult::RESULT_FAIL, | |||||
ArcanistUnitTestResult::RESULT_SKIP, | |||||
ArcanistUnitTestResult::RESULT_PASS, | |||||
), | |||||
'expected' => ArcanistUnitTestResult::RESULT_FAIL, | |||||
); | |||||
$test_sets['all pass'] = array( | |||||
'input' => array( | |||||
ArcanistUnitTestResult::RESULT_PASS, | |||||
ArcanistUnitTestResult::RESULT_PASS, | |||||
ArcanistUnitTestResult::RESULT_PASS, | |||||
), | |||||
'expected' => ArcanistUnitTestResult::RESULT_PASS, | |||||
); | |||||
foreach ($test_sets as $key => $set) { | |||||
$input = $set['input']; | |||||
$expected = $set['expected']; | |||||
$result = HarbormasterUnitStatus::summarizeStatuses($input); | |||||
$this->assertEqual($expected, $result, 'test case: '.$key); | |||||
} | |||||
} | |||||
} |