Exemplo n.º 1
0
 public function testSort()
 {
     $first = new TestModel();
     $first->name = 'Thing A';
     $second = new TestModel();
     $second->name = 'thing B';
     $third = new TestModel();
     $third->name = 'Thing C';
     $fourth = new TestModel();
     $fourth->name = 'Thing D';
     $fifth = new TestModel();
     $fifth->name = 'Thing E';
     $sixth = new TestModel();
     $sixth->name = 'Thing F';
     $seventh = new TestModel();
     $seventh->name = 'Thing G';
     $eighth = new TestModel();
     $eighth->name = 'Thing H';
     $ninth = new TestModel();
     $ninth->name = 'Thing I';
     $tenth = new TestModel();
     $tenth->name = 'Thing J';
     $arr = [$second, $sixth, $ninth, $fifth, $third, $tenth, $fourth, $first, $seventh, $eighth];
     Nymph::sort($arr, 'name');
     $this->assertEquals([$first, $second, $third, $fourth, $fifth, $sixth, $seventh, $eighth, $ninth, $tenth], $arr);
     Nymph::sort($arr, 'name', true, true);
     $this->assertEquals(array_reverse([$first, $third, $fourth, $fifth, $sixth, $seventh, $eighth, $ninth, $tenth, $second]), $arr);
 }