ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
AlphanumericTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8namespace ILIAS\Data;
9
11use PHPUnit\Framework\TestCase;
12
13require_once('./libs/composer/vendor/autoload.php');
14
15class AlphanumericTest extends TestCase
16{
18 {
19 $value = new Alphanumeric('hello');
20
21 $this->assertSame('hello', $value->asString());
22 }
23
25 {
26 $value = new Alphanumeric(6);
27
28 $this->assertSame('6', $value->asString());
29 }
30
32 {
33 $value = new Alphanumeric(6);
34
35 $this->assertSame(6, $value->getValue());
36 }
37
39 {
40 $value = new Alphanumeric(6.0);
41
42 $this->assertSame('6', $value->asString());
43 }
44
46 {
47 $value = new Alphanumeric(6.0);
48
49 $this->assertSame(6.0, $value->getValue());
50 }
51
53 {
54 $this->expectNotToPerformAssertions();
55
56 try {
57 $value = new Alphanumeric('hello world');
58 } catch (ConstraintViolationException $exception) {
59 return;
60 }
61 $this->fail();
62 }
63}
An exception for terminatinating execution or to throw for unit testing.
testSimpleStringIsCorrectAlphanumericValueAndCanBeConvertedToString()