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