ILIAS  release_8 Revision v8.24
PositiveIntegerTest.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 PositiveIntegerTest extends TestCase
19{
23 public function testCreatePositiveInteger(): void
24 {
25 $integer = new PositiveInteger(6);
26 $this->assertSame(6, $integer->getValue());
27 }
28
29 public function testNegativeIntegerThrowsException(): void
30 {
31 $this->expectNotToPerformAssertions();
32
33 try {
34 $integer = new PositiveInteger(-6);
35 } catch (ConstraintViolationException $exception) {
36 return;
37 }
38 $this->fail();
39 }
40
44 public function testMaximumIntegerIsAccepted(): void
45 {
46 $integer = new PositiveInteger(PHP_INT_MAX);
47 $this->assertSame(PHP_INT_MAX, $integer->getValue());
48 }
49}