ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
FactoryTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Tests\Refinery;
22
23use ILIAS\Refinery\ByTrying as ByTrying;
24use ILIAS\Refinery\Container\Group as ContainerGroup;
25use ILIAS\Refinery\Custom\Group as CustomGroup;
26use ILIAS\Refinery\DateTime\Group as DateTimeGroup;
27use ILIAS\Refinery\Factory as Refinery;
28use ILIAS\Data\Factory as DataFactory;
31use ILIAS\Refinery\In\Group as InGroup;
32use ILIAS\Refinery\Integer\Group as IntegerGroup;
33use ILIAS\Refinery\Logical\Group as LogicalGroup;
34use ILIAS\Refinery\Numeric\Group as NumericGroup;
35use ILIAS\Refinery\Password\Group as PasswordGroup;
36use ILIAS\Refinery\String\Group as StringGroup;
37use ILIAS\Refinery\To\Group as ToGroup;
38use ILIAS\Refinery\URI\Group as URIGroup;
39use ILIAS\Refinery\Decode\Group as DecodeGroup;
40use ILIAS\Refinery\Encode\Group as EncodeGroup;
41use PHPUnit\Framework\TestCase;
42use PHPUnit\Framework\MockObject\Stub;
43
44class FactoryTest extends TestCase
45{
47
48 protected function setUp(): void
49 {
51 $language = $this->createStub(\ILIAS\Language\Language::class);
52
53 $this->basicFactory = new Refinery(new DataFactory(), $language);
54 }
55
56 public function testCreateToGroup(): void
57 {
58 $group = $this->basicFactory->to();
59
60 $this->assertInstanceOf(ToGroup::class, $group);
61 }
62
63 public function testCreateInGroup(): void
64 {
65 $group = $this->basicFactory->in();
66
67 $this->assertInstanceOf(InGroup::class, $group);
68 }
69
70 public function testCreateIntegerGroup(): void
71 {
72 $group = $this->basicFactory->int();
73
74 $this->assertInstanceOf(IntegerGroup::class, $group);
75 }
76
77 public function testCreateStringGroup(): void
78 {
79 $group = $this->basicFactory->string();
80
81 $this->assertInstanceOf(StringGroup::class, $group);
82 }
83
84 public function testCreateNumericGroup(): void
85 {
86 $group = $this->basicFactory->numeric();
87
88 $this->assertInstanceOf(NumericGroup::class, $group);
89 }
90
91 public function testCreateLogicalGroup(): void
92 {
93 $group = $this->basicFactory->logical();
94
95 $this->assertInstanceOf(LogicalGroup::class, $group);
96 }
97
98 public function testCreatePasswordGroup(): void
99 {
100 $group = $this->basicFactory->password();
101
102 $this->assertInstanceOf(PasswordGroup::class, $group);
103 }
104
105 public function testCreateCustomGroup(): void
106 {
107 $group = $this->basicFactory->custom();
108
109 $this->assertInstanceOf(CustomGroup::class, $group);
110 }
111
112 public function testCreateContainerGroup(): void
113 {
114 $group = $this->basicFactory->container();
115
116 $this->assertInstanceOf(ContainerGroup::class, $group);
117 }
118
119 public function testCreateDateTimeGroup(): void
120 {
121 $group = $this->basicFactory->dateTime();
122 $this->assertInstanceOf(DateTimeGroup::class, $group);
123 }
124
125 public function testCreateUriGroup(): void
126 {
127 $group = $this->basicFactory->uri();
128 $this->assertInstanceOf(URIGroup::class, $group);
129 }
130
131 public function testCreateEncodeGroup(): void
132 {
133 $this->assertInstanceOf(EncodeGroup::class, $this->basicFactory->encode());
134 }
135
136 public function testCreateDecodeGroup(): void
137 {
138 $this->assertInstanceOf(DecodeGroup::class, $this->basicFactory->decode());
139 }
140
141 public function testByTryingInGroup(): void
142 {
143 $instance = $this->basicFactory->byTrying([
144 $this->basicFactory->numeric(),
145 $this->basicFactory->string()
146 ]);
147 $this->assertInstanceOf(ByTrying::class, $instance);
148 }
149
150 public function testIdentity(): void
151 {
152 $instance = $this->basicFactory->identity();
153 $this->assertInstanceOf(IdentityTransformation::class, $instance);
154 }
155
156 public function testExecutable(): void
157 {
158 $instance = $this->basicFactory->executable();
159 $this->assertInstanceOf(IsExecutableTransformation::class, $instance);
160 }
161}
Builds data types.
Definition: Factory.php:36
Validates that the given string is a valid and executable file path.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.