public function testSortCustomOrder()
 {
     $order = ["d", "k", "a", "b", "c"];
     Collections::sort($this->numeratedArrayList, new MyCustomOrderComparator(Comparator::ORDER_CUSTOM, $order));
     for ($i = 0; $i < count($order); ++$i) {
         $this->assertTrue($order[$i] === $this->numeratedArrayList->get($i)->getAttr1());
     }
 }
Beispiel #2
0
 public function testAdd()
 {
     $list = new ArrayList(['a' => 'aa', 'b' => 'bb', 'c' => 'cc']);
     $list->add('d', 'dd');
     $this->assertEquals('dd', $list->get('d'));
     $list->add('d', 'ddd');
     $dl = $list->get('d');
     $this->assertTrue(is_array($dl));
     $this->assertEquals('dd', $dl[0]);
     $this->assertEquals('ddd', $dl[1]);
 }