ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
OrderTest.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
5 
9 class orderTest extends TestCase
10 {
11  public function testFactory()
12  {
13  $f = new ILIAS\Data\Factory();
14  $order = $f->order('subject', Order::ASC);
15  $this->assertInstanceOf(Order::class, $order);
16  return $order;
17  }
18 
22  public function testValues(Order $order)
23  {
24  $this->assertEquals(
25  ['subject' => Order::ASC],
26  $order->get()
27  );
28  }
29 
33  public function testAppend(Order $order)
34  {
35  $order = $order->append('sub2', Order::DESC);
36  $this->assertEquals(
37  [
38  'subject' => Order::ASC,
39  'sub2' => Order::DESC
40  ],
41  $order->get()
42  );
43  return $order;
44  }
45 
49  public function testJoinOne(Order $order)
50  {
51  $this->assertEquals(
52  'SORT BY subject ASC',
53  $order->join(
54  'SORT BY',
55  function ($pre, $k, $v) {
56  return "$pre $k $v";
57  }
58  )
59  );
60  }
61 
65  public function testJoinMore(Order $order)
66  {
67  $this->assertEquals(
68  'Sorting subject ASC, sub2 DESC,',
69  $order->join(
70  'Sorting',
71  function ($pre, $k, $v) {
72  return "$pre $k $v,";
73  }
74  )
75  );
76  }
77 
81  public function testInvalidDirection(Order $order)
82  {
83  $this->expectException(InvalidArgumentException::class);
84  $order = $order->append('sub3', -1);
85  }
86 
90  public function testInvalidSubject(Order $order)
91  {
92  $this->expectException(InvalidArgumentException::class);
93  $order = $order->append('subject', Order::ASC);
94  }
95 }
testFactory()
Definition: OrderTest.php:11
join($init, callable $fn)
Definition: Order.php:54
testJoinMore(Order $order)
testAppend
Definition: OrderTest.php:65
testValues(Order $order)
testFactory
Definition: OrderTest.php:22
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:10
testJoinOne(Order $order)
testFactory
Definition: OrderTest.php:49
append(string $subject, $direction)
Definition: Order.php:40
testInvalidSubject(Order $order)
testFactory
Definition: OrderTest.php:90
testInvalidDirection(Order $order)
testFactory
Definition: OrderTest.php:81
testAppend(Order $order)
testFactory
Definition: OrderTest.php:33