4 require_once(
"libs/composer/vendor/autoload.php");
22 protected function setUp() : void
24 $this->f =
new Data\Factory();
35 $this->assertInstanceOf(Data\Result::class,
$result);
36 $this->assertTrue(
$result->isOk());
37 $this->assertFalse(
$result->isError());
42 $result = $this->f->error(
"Something went wrong");
43 $this->assertInstanceOf(Data\Result::class,
$result);
44 $this->assertTrue(
$result->isError());
45 $this->assertFalse(
$result->isOk());
50 $pwd = $this->f->password(
"secret");
51 $this->assertInstanceOf(Data\Password::class, $pwd);
56 $dataType = $this->f->alphanumeric(
'someValue');
57 $this->assertInstanceOf(Data\Alphanumeric::class, $dataType);
62 $dataType = $this->f->positiveInteger(100);
63 $this->assertInstanceOf(Data\PositiveInteger::class, $dataType);
68 $dataType = $this->f->openedIntegerInterval(1, 100);
69 $this->assertInstanceOf(Data\Interval\OpenedIntegerInterval::class, $dataType);
74 $dataType = $this->f->closedIntegerInterval(1, 100);
75 $this->assertInstanceOf(Data\Interval\ClosedIntegerInterval::class, $dataType);
80 $dataType = $this->f->openedFloatInterval(1.4, 100.2);
81 $this->assertInstanceOf(Data\Interval\OpenedFloatInterval::class, $dataType);
86 $dataType = $this->f->closedFloatInterval(1.4, 100.2);
87 $this->assertInstanceOf(Data\Interval\ClosedFloatInterval::class, $dataType);
92 $dataType = $this->f->dataSize(10,
"MB");
93 $this->assertInstanceOf(Data\DataSize::class, $dataType);
98 $dataType = $this->f->dataSize(
"10G");
99 $this->assertEquals(10, $dataType->getSize());
100 $this->assertEquals(Data\DataSize::GiB, $dataType->getUnit());
101 $this->assertEquals(10 * Data\DataSize::GiB, $dataType->inBytes());
102 $this->assertInstanceOf(Data\DataSize::class, $dataType);
Testing the faytory of result objects.