19 declare(strict_types=1);
21 require_once(
"vendor/composer/vendor/autoload.php");
38 private ?Data\Factory
$f;
40 protected function setUp(): void
42 $this->f =
new Data\Factory();
52 $result = $this->f->ok(3.154);
53 $this->assertInstanceOf(
Data\Result::class, $result);
54 $this->assertTrue($result->isOk());
55 $this->assertFalse($result->isError());
60 $result = $this->f->error(
"Something went wrong");
61 $this->assertInstanceOf(
Data\Result::class, $result);
62 $this->assertTrue($result->isError());
63 $this->assertFalse($result->isOk());
68 $pwd = $this->f->password(
"secret");
69 $this->assertInstanceOf(
Data\Password::class, $pwd);
74 $dataType = $this->f->alphanumeric(
'someValue');
75 $this->assertInstanceOf(
Data\Alphanumeric::class, $dataType);
80 $dataType = $this->f->positiveInteger(100);
81 $this->assertInstanceOf(
Data\PositiveInteger::class, $dataType);
86 $dataType = $this->f->dataSize(10,
"MB");
87 $this->assertInstanceOf(
Data\DataSize::class, $dataType);
92 $dataType = $this->f->dataSize(
"10G");
93 $this->assertEquals(10, $dataType->getSize());
94 $this->assertEquals(
Data\DataSize::GiB, $dataType->getUnit());
95 $this->assertEquals(10 *
Data\DataSize::GiB, $dataType->inBytes());
96 $this->assertInstanceOf(
Data\DataSize::class, $dataType);
101 $tag = $this->f->languageTag(
'de');
102 $this->assertInstanceOf(LanguageTag::class, $tag);
107 $this->expectException(NotOKException::class);
108 $this->f->languageTag(
'd$');
Testing the faytory of result objects.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null