function testJunctions()
 {
     $junctions = new Collection($this->backend->junctions);
     $actual = $junctions->orderBy('name')->select('name', null)->toArray();
     $expected = ['Membership', 'Rating'];
     $this->assertEquals($expected, $actual);
 }
 public function orderBy($selector, $method = SORT_REGULAR)
 {
     if ($this->isConverted === false && is_string($selector) && isset($this->options['mapping'][$selector]) && $this->data instanceof Collection) {
         return new self($this->data->orderBy($this->options['mapping'][$selector], $method), $this->model, $this->repository, $this->options);
     }
     return parent::orderBy($selector, $method);
 }
 /**
  * Return a new collection sorted by the given field in ascending order.
  *
  * @param string $selector
  * @param int    $method   The sorting method, options are: SORT_REGULAR, SORT_NUMERIC, SORT_STRING or SORT_NATURAL
  *
  * @return Collection
  */
 public function orderBy($selector, $method = SORT_REGULAR)
 {
     if ($this->data === null && $method == SORT_REGULAR && is_string($selector) && is_string($this->sql) === false && is_array($this->sql->orderBy) && $this->sql->limit === false && $this->sql->offset == 0) {
         $sql = clone $this->sql;
         \Sledgehammer\array_key_unshift($sql->orderBy, $selector, 'ASC');
         return new self($sql, $this->dbLink);
     }
     return parent::orderBy($selector, $method);
 }