ILIAS  release_8 Revision v8.24
AlphanumericTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
6
11namespace ILIAS\Data;
12
14use PHPUnit\Framework\TestCase;
15
16require_once('./libs/composer/vendor/autoload.php');
17
18class AlphanumericTest extends TestCase
19{
21 {
22 $value = new Alphanumeric('hello');
23
24 $this->assertSame('hello', $value->asString());
25 }
26
28 {
29 $value = new Alphanumeric(6);
30
31 $this->assertSame('6', $value->asString());
32 }
33
34 public function testIntegerIsAlphanumericValue(): void
35 {
36 $value = new Alphanumeric(6);
37
38 $this->assertSame(6, $value->getValue());
39 }
40
42 {
43 $value = new Alphanumeric(6.0);
44
45 $this->assertSame('6', $value->asString());
46 }
47
48 public function testFloatIsAlphanumericValue(): void
49 {
50 $value = new Alphanumeric(6.0);
51
52 $this->assertSame(6.0, $value->getValue());
53 }
54
56 {
57 $this->expectNotToPerformAssertions();
58
59 try {
60 $value = new Alphanumeric('hello world');
61 } catch (ConstraintViolationException $exception) {
62 return;
63 }
64 $this->fail();
65 }
66}
testSimpleStringIsCorrectAlphanumericValueAndCanBeConvertedToString()