summaryrefslogtreecommitdiffstats
path: root/tests/src/Unit/Plugin
diff options
context:
space:
mode:
authorJoris Vercammen2015-10-24 13:54:59 (GMT)
committerJoris Vercammen2015-10-24 13:54:59 (GMT)
commitf328d6544cb3f61a6a787e6972e40db61f5d3f6d (patch)
tree4ef754125dfddb5061c8eb3082cf29fe4b8f16c9 /tests/src/Unit/Plugin
parentdeeb1499e4825dd6435e41df3795061ec88e780c (diff)
Issue #2600402 by mr.baileys, borisson_: Split ResultInterface::getValue() into getRawValue() and getDisplayValue()
Diffstat (limited to 'tests/src/Unit/Plugin')
-rw-r--r--tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php18
-rw-r--r--tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php31
-rw-r--r--tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php10
3 files changed, 36 insertions, 23 deletions
diff --git a/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
index 8399b8c..0586ec8 100644
--- a/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/CountWidgetOrderProcessorTest.php
@@ -38,9 +38,9 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
parent::setUp();
$this->original_results = [
- new Result('llama', 10),
- new Result('badger', 5),
- new Result('duck', 15),
+ new Result('llama', 'llama', 10),
+ new Result('badger', 'badger', 5),
+ new Result('duck', 'duck', 15),
];
$this->processor = new CountWidgetOrderProcessor([], 'count_widget_order', []);
@@ -54,11 +54,11 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
$sorted_results = $this->processor->sortResults($this->original_results, 'ASC');
$this->assertEquals(5, $sorted_results[0]->getCount());
- $this->assertEquals('badger', $sorted_results[0]->getValue());
+ $this->assertEquals('badger', $sorted_results[0]->getDisplayValue());
$this->assertEquals(10, $sorted_results[1]->getCount());
- $this->assertEquals('llama', $sorted_results[1]->getValue());
+ $this->assertEquals('llama', $sorted_results[1]->getDisplayValue());
$this->assertEquals(15, $sorted_results[2]->getCount());
- $this->assertEquals('duck', $sorted_results[2]->getValue());
+ $this->assertEquals('duck', $sorted_results[2]->getDisplayValue());
}
/**
@@ -69,11 +69,11 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
$sorted_results = $this->processor->sortResults($this->original_results, 'DESC');
$this->assertEquals(15, $sorted_results[0]->getCount());
- $this->assertEquals('duck', $sorted_results[0]->getValue());
+ $this->assertEquals('duck', $sorted_results[0]->getDisplayValue());
$this->assertEquals(10, $sorted_results[1]->getCount());
- $this->assertEquals('llama', $sorted_results[1]->getValue());
+ $this->assertEquals('llama', $sorted_results[1]->getDisplayValue());
$this->assertEquals(5, $sorted_results[2]->getCount());
- $this->assertEquals('badger', $sorted_results[2]->getValue());
+ $this->assertEquals('badger', $sorted_results[2]->getDisplayValue());
}
}
diff --git a/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php b/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
index d7788ac..3794284 100644
--- a/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/DisplayValueWidgetOrderProcessorTest.php
@@ -38,13 +38,13 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
parent::setUp();
$this->original_results = [
- new Result('thetans', 10),
- new Result('xenu', 5),
- new Result('Tom', 15),
- new Result('Hubbard', 666),
- new Result('FALSE', 1),
- new Result('1977', 20),
- new Result('2', 22),
+ new Result('thetans', 'thetans', 10),
+ new Result('xenu', 'xenu', 5),
+ new Result('Tom', 'Tom', 15),
+ new Result('Hubbard', 'Hubbard', 666),
+ new Result('FALSE', 'FALSE', 1),
+ new Result('1977', '1977', 20),
+ new Result('2', '2', 22),
];
$this->processor = new DisplayValueWidgetOrderProcessor([], 'display_value_widget_order', []);
@@ -57,7 +57,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
$sorted_results = $this->processor->sortResults($this->original_results, 'ASC');
$expected_values = array('2', '1977', 'FALSE', 'Hubbard', 'thetans', 'Tom', 'xenu');
foreach ($expected_values as $index => $value) {
- $this->assertEquals($value, $sorted_results[$index]->getValue());
+ $this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
}
}
@@ -68,8 +68,21 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
$sorted_results = $this->processor->sortResults($this->original_results, 'DESC');
$expected_values = array_reverse(array('2', '1977', 'FALSE', 'Hubbard', 'thetans', 'Tom', 'xenu'));
foreach ($expected_values as $index => $value) {
- $this->assertEquals($value, $sorted_results[$index]->getValue());
+ $this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
}
}
+ public function testUseActualDisplayValue() {
+ $original = [
+ new Result('bb_test', 'Test AA', 10),
+ new Result('aa_test', 'Test BB', 10),
+ ];
+
+ $sorted_results = $this->processor->sortResults($original, 'DESC');
+
+ $this->assertEquals('Test BB', $sorted_results[0]->getDisplayValue());
+ $this->assertEquals('Test AA', $sorted_results[1]->getDisplayValue());
+
+ }
+
}
diff --git a/tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php b/tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php
index bdc55fd..5e87bc8 100644
--- a/tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php
+++ b/tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php
@@ -39,9 +39,9 @@ class MinimumCountProcessorTest extends UnitTestCase {
parent::setUp();
$this->original_results = [
- new Result('llama', 10),
- new Result('badger', 5),
- new Result('duck', 15),
+ new Result('llama', 'llama', 10),
+ new Result('badger', 'badger', 5),
+ new Result('duck', 'duck', 15),
];
$this->processor = new MinimumCountProcessor([], 'minimum_count', []);
@@ -65,9 +65,9 @@ class MinimumCountProcessorTest extends UnitTestCase {
$this->assertCount(2, $sorted_results);
$this->assertEquals(10, $sorted_results[0]->getCount());
- $this->assertEquals('llama', $sorted_results[0]->getValue());
+ $this->assertEquals('llama', $sorted_results[0]->getDisplayValue());
$this->assertEquals(15, $sorted_results[2]->getCount());
- $this->assertEquals('duck', $sorted_results[2]->getValue());
+ $this->assertEquals('duck', $sorted_results[2]->getDisplayValue());
}
}