aboutsummaryrefslogtreecommitdiff
path: root/test/SortByFieldExtensionTest.php
diff options
context:
space:
mode:
authorVictor Häggqvist <[email protected]>2015-11-17 17:33:40 +0100
committerVictor Häggqvist <[email protected]>2015-11-17 17:33:40 +0100
commitef96b728d2395f26f246f0ae97d89200f860f264 (patch)
treec73227f38e9ab45b071873210f4f585872d74e2a /test/SortByFieldExtensionTest.php
parentf9be3024b81f2d272ad59649ce37c2ec0e7ac04b (diff)
add test for parent array with keys
Diffstat (limited to '')
-rw-r--r--test/SortByFieldExtensionTest.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/SortByFieldExtensionTest.php b/test/SortByFieldExtensionTest.php
index ff15a35..be06301 100644
--- a/test/SortByFieldExtensionTest.php
+++ b/test/SortByFieldExtensionTest.php
@@ -61,6 +61,48 @@ class SortByFieldExtensionTest extends PHPUnit_Framework_TestCase {
}
}
+ public function testSortArrayWithKeys() {
+ $base = array(
+ "a" => array(
+ "name" => "Redmine",
+ "desc" => "Issues Tracker",
+ "url" => "http://www.redmine.org/",
+ "oss" => "GPL",
+ "cost" => 0
+ ),
+ "b" => array(
+ "name" => "GitLab",
+ "desc" => "Version Control",
+ "url" => "https://about.gitlab.com/",
+ "oss" => "GPL",
+ "cost" => 1,
+ ),
+ "c" => array(
+ "name" => "Jenkins",
+ "desc" => "Continous Integration",
+ "url" => "http://jenkins-ci.org/",
+ "oss" => "MIT",
+ "cost" => 0,
+ ),
+ "d" => array(
+ "name" => "Piwik",
+ "desc" => "Web Analytics",
+ "url" => "http://piwik.org/",
+ "oss" => "GPL",
+ "cost" => 1
+ )
+ );
+
+ $fact = array('GitLab','Jenkins','Piwik','Redmine');
+
+ $filter = new SortByFieldExtension();
+ $sorted = $filter->sortByFieldFilter($base,'name');
+
+ for ($i = 0; $i < count($fact); $i++){
+ $this->assertEquals($fact[$i], $sorted[$i]['name']);
+ }
+ }
+
public function testSortObjects() {
$base = array();
$ob1 = new Foo();