ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
BuildProcessAndDataObjectsTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 
29 class BuildProcessAndDataObjectsTest extends TestCase
30 {
31  public function testStandard(): void
32  {
33  $factory = new Factory();
34 
35  $vocab = $factory->standard(
36  SlotIdentifier::LIFECYCLE_STATUS,
37  'value 1',
38  'value 2'
39  )->get();
40 
41  $this->assertSame(SlotIdentifier::LIFECYCLE_STATUS, $vocab->slot());
42  $this->assertSame(Type::STANDARD, $vocab->type());
43  $this->assertSame(SlotIdentifier::LIFECYCLE_STATUS->value, $vocab->id());
44  $this->assertSame(FactoryInterface::STANDARD_SOURCE, $vocab->source());
45  $this->assertSame(['value 1', 'value 2'], iterator_to_array($vocab->values()));
46  $this->assertTrue($vocab->isActive());
47  }
48 
49  public function testStandardInactive(): void
50  {
51  $factory = new Factory();
52 
53  $vocab = $factory->standard(
54  SlotIdentifier::LIFECYCLE_STATUS,
55  'value 1',
56  'value 2'
57  )->withIsDeactivated(true)->get();
58 
59  $this->assertFalse($vocab->isActive());
60  }
61 
62  public function testControlledString(): void
63  {
64  $factory = new Factory();
65 
66  $vocab = $factory->controlledString(
67  SlotIdentifier::GENERAL_COVERAGE,
68  'some identifier',
69  'some source',
70  'value 1',
71  'value 2'
72  )->get();
73 
74  $this->assertSame(SlotIdentifier::GENERAL_COVERAGE, $vocab->slot());
75  $this->assertSame(Type::CONTROLLED_STRING, $vocab->type());
76  $this->assertSame('some identifier', $vocab->id());
77  $this->assertSame('some source', $vocab->source());
78  $this->assertSame(['value 1', 'value 2'], iterator_to_array($vocab->values()));
79  $this->assertTrue($vocab->isActive());
80  $this->assertTrue($vocab->allowsCustomInputs());
81  }
82 
83  public function testControlledStringInactive(): void
84  {
85  $factory = new Factory();
86 
87  $vocab = $factory->controlledString(
88  SlotIdentifier::GENERAL_COVERAGE,
89  'some identifier',
90  'some source',
91  'value 1',
92  'value 2'
93  )->withIsDeactivated(true)->get();
94 
95  $this->assertFalse($vocab->isActive());
96  }
97 
99  {
100  $factory = new Factory();
101 
102  $vocab = $factory->controlledString(
103  SlotIdentifier::GENERAL_COVERAGE,
104  'some identifier',
105  'some source',
106  'value 1',
107  'value 2'
108  )->withDisallowsCustomInputs(true)->get();
109 
110  $this->assertFalse($vocab->allowsCustomInputs());
111  }
112 
113  public function testControlledVocabValue(): void
114  {
115  $factory = new Factory();
116 
117  $vocab = $factory->controlledVocabValue(
118  SlotIdentifier::GENERAL_COVERAGE,
119  'some identifier',
120  'some source',
121  'value 1',
122  'value 2'
123  )->get();
124 
125  $this->assertSame(SlotIdentifier::GENERAL_COVERAGE, $vocab->slot());
126  $this->assertSame(Type::CONTROLLED_VOCAB_VALUE, $vocab->type());
127  $this->assertSame('some identifier', $vocab->id());
128  $this->assertSame('some source', $vocab->source());
129  $this->assertSame(['value 1', 'value 2'], iterator_to_array($vocab->values()));
130  $this->assertTrue($vocab->isActive());
131  $this->assertTrue($vocab->allowsCustomInputs());
132  }
133 
134  public function testControlledVocabValueInactive(): void
135  {
136  $factory = new Factory();
137 
138  $vocab = $factory->controlledVocabValue(
139  SlotIdentifier::GENERAL_COVERAGE,
140  'some identifier',
141  'some source',
142  'value 1',
143  'value 2'
144  )->withIsDeactivated(true)->get();
145 
146  $this->assertFalse($vocab->isActive());
147  }
148 
149  public function testCopyright(): void
150  {
151  $factory = new Factory();
152 
153  $vocab = $factory->copyright(
154  'value 1',
155  'value 2'
156  )->get();
157 
158  $this->assertSame(SlotIdentifier::RIGHTS_DESCRIPTION, $vocab->slot());
159  $this->assertSame(Type::COPYRIGHT, $vocab->type());
160  $this->assertSame(SlotIdentifier::RIGHTS_DESCRIPTION->value, $vocab->id());
161  $this->assertSame(FactoryInterface::COPYRIGHT_SOURCE, $vocab->source());
162  $this->assertSame(['value 1', 'value 2'], iterator_to_array($vocab->values()));
163  $this->assertTrue($vocab->isActive());
164  }
165 
166  public function testNull(): void
167  {
168  $factory = new Factory();
169 
170  $vocab = $factory->null();
171 
172  $this->assertInstanceOf(NullVocabulary::class, $vocab);
173  }
174 }
$vocab