aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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();