From ef96b728d2395f26f246f0ae97d89200f860f264 Mon Sep 17 00:00:00 2001 From: Victor Häggqvist Date: Tue, 17 Nov 2015 17:33:40 +0100 Subject: add test for parent array with keys --- test/SortByFieldExtensionTest.php | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) 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(); -- cgit v1.2.3