ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
SelectSpecificDataTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 
25 class SelectSpecificDataTest extends TestCase
26 {
27  public function testGetOptionsSortedByPosition(): void
28  {
29  $option_1 = new OptionImplementation(5, 13);
30  $option_2 = new OptionImplementation(0, 13);
31  $option_3 = new OptionImplementation(32, 13);
32  $data = new SelectSpecificDataImplementation(1, $option_1, $option_2, $option_3);
33 
34  $options = $data->getOptions();
35  $this->assertSame(
36  $option_2,
37  $options->current()
38  );
39  $options->next();
40  $this->assertSame(
41  $option_1,
42  $options->current()
43  );
44  $options->next();
45  $this->assertSame(
46  $option_3,
47  $options->current()
48  );
49  }
50 
51  public function testHasOptionsTrue(): void
52  {
53  $option = new OptionImplementation(5, 13);
54  $data = new SelectSpecificDataImplementation(1, $option);
55  $this->assertTrue($data->hasOptions());
56  }
57 
58  public function testHasOptionsFalse(): void
59  {
61  $this->assertFalse($data->hasOptions());
62  }
63 
64  public function testGetOption(): void
65  {
66  $option = new OptionImplementation(5, 13);
67  $data = new SelectSpecificDataImplementation(1, $option);
68  $this->assertSame(
69  $option,
70  $data->getOption(13)
71  );
72  }
73 
74  public function testAddOption(): void
75  {
77  $option = $data->addOption();
78  $this->assertSame(
79  $option,
80  $data->getOptions()->current()
81  );
82  }
83 
84  public function testRemoveOption(): void
85  {
86  $option = new OptionImplementation(5, 13);
87  $data = new SelectSpecificDataImplementation(1, $option);
88  $data->removeOption(13);
89  $this->assertNull($data->getOption(13));
90  }
91 
92  public function testContainsChangesOptionRemoved(): void
93  {
94  $option = new OptionImplementation(5, 13);
95  $data = new SelectSpecificDataImplementation(1, $option);
96  $data->removeOption(13);
97  $this->assertTrue($data->containsChanges());
98  }
99 }