public function testPreservesInputConfigData() { $config = new \stdClass(); $list = new \ElggPriorityList(); $obj1 = (object) array('name' => 'bar1', 'url' => '#', 'loaded' => false, 'location' => 'custom_location'); $obj2 = (object) array('name' => 'bar2', 'url' => 'http://elgg.org/', 'loaded' => true, 'location' => 'custom_location'); $list->add($obj1, 600); $list->add($obj2, 300); $GLOBALS['_ELGG']->externals = array('foo' => $list); $GLOBALS['_ELGG']->externals_map = array('foo' => array('bar1' => $obj1, 'bar2' => $obj2)); $externalFiles = new \Elgg\Assets\ExternalFiles($config); $this->assertEquals(array(300 => 'http://elgg.org/'), $externalFiles->getLoadedFiles('foo', 'custom_location')); $externalFiles->load('foo', 'bar1'); $this->assertEquals(array(300 => 'http://elgg.org/', 600 => '#'), $externalFiles->getLoadedFiles('foo', 'custom_location')); }
public function testUserSort() { $elements = array('A', 'B', 'C', 'D', 'E'); $elements_sorted_string = $elements; shuffle($elements); $pl = new ElggPriorityList($elements); // will sort by priority $test_elements = $pl->getElements(); $this->assertSame($elements, $test_elements); function test_sort($elements) { sort($elements, SORT_LOCALE_STRING); return $elements; } // force a new sort using our function $pl->sort('test_sort'); $test_elements = $pl->getElements(); $this->assertSame($elements_sorted_string, $test_elements); }