ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AlphanumericTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24namespace ILIAS\Data;
25
27use PHPUnit\Framework\TestCase;
28
29require_once('./vendor/composer/vendor/autoload.php');
30
31class AlphanumericTest extends TestCase
32{
34 {
35 $value = new Alphanumeric('hello');
36
37 $this->assertSame('hello', $value->asString());
38 }
39
41 {
42 $value = new Alphanumeric(6);
43
44 $this->assertSame('6', $value->asString());
45 }
46
47 public function testIntegerIsAlphanumericValue(): void
48 {
49 $value = new Alphanumeric(6);
50
51 $this->assertSame(6, $value->getValue());
52 }
53
55 {
56 $value = new Alphanumeric(6.0);
57
58 $this->assertSame('6', $value->asString());
59 }
60
61 public function testFloatIsAlphanumericValue(): void
62 {
63 $value = new Alphanumeric(6.0);
64
65 $this->assertSame(6.0, $value->getValue());
66 }
67
69 {
70 $this->expectNotToPerformAssertions();
71
72 try {
73 $value = new Alphanumeric('hello world');
74 } catch (ConstraintViolationException $exception) {
75 return;
76 }
77 $this->fail();
78 }
79}
testSimpleStringIsCorrectAlphanumericValueAndCanBeConvertedToString()