aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Foo.php13
-rw-r--r--test/SortByFieldExtensionTest.php28
2 files changed, 41 insertions, 0 deletions
diff --git a/test/Foo.php b/test/Foo.php
index e6e688c..4b6148b 100644
--- a/test/Foo.php
+++ b/test/Foo.php
@@ -7,4 +7,17 @@
class Foo {
public $name;
+ private $attrs = array();
+
+ public function __isset($name) {
+ return isset($this->attrs[$name]);
+ }
+
+ public function __get($name) {
+ return $this->attrs[$name];
+ }
+
+ public function __set($name, $value) {
+ $this->attrs[$name] = $value;
+ }
}
diff --git a/test/SortByFieldExtensionTest.php b/test/SortByFieldExtensionTest.php
index 64bd11e..ff15a35 100644
--- a/test/SortByFieldExtensionTest.php
+++ b/test/SortByFieldExtensionTest.php
@@ -89,6 +89,34 @@ class SortByFieldExtensionTest extends PHPUnit_Framework_TestCase {
}
}
+ public function testSortObjectsMagicProperty() {
+ $base = array();
+ $ob1 = new Foo();
+ $ob1->magicName = "Redmine";
+ $base[]=$ob1;
+
+ $ob2 = new Foo();
+ $ob2->magicName = "GitLab";
+ $base[]=$ob2;
+
+ $ob3 = new Foo();
+ $ob3->magicName = "Jenkins";
+ $base[]=$ob3;
+
+ $ob4 = new Foo();
+ $ob4->magicName = "Jenkins";
+ $base[]=$ob4;
+
+ $fact = array('GitLab','Jenkins','Jenkins','Redmine');
+
+ $filter = new SortByFieldExtension();
+ $sorted = $filter->sortByFieldFilter($base,'magicName');
+
+ for ($i = 0; $i < count($fact); $i++){
+ $this->assertEquals($fact[$i], $sorted[$i]->magicName);
+ }
+ }
+
public function testNonArrayBase() {
$filter = new SortByFieldExtension();
$this->setExpectedException('InvalidArgumentException');