ILIAS  release_8 Revision v8.25
ilSystemStyleExceptionBaseTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once('libs/composer/vendor/autoload.php');
22
23use PHPUnit\Framework\TestCase;
24
25abstract class ilSystemStyleExceptionBaseTest extends TestCase
26{
27 abstract protected function getClassName(): string;
28
29 public function codesProvider(): array
30 {
31 $reflection = new ReflectionClass($this->getClassName());
32
33 $constant_values = array_values($reflection->getConstants());
34 return array_map(function ($val) {
35 return [$val];
36 }, $constant_values);
37 }
38
42 public function testConstruct(int $code): void
43 {
44 $class_name = $this->getClassName();
45 $this->assertInstanceOf($class_name, new $class_name($code, 'Additional Info'));
46 }
47
51 public function testAssignMessageToCode(int $code): void
52 {
53 $class_name = $this->getClassName();
54 $exception = new $class_name($code, 'Additional Info');
55 $this->assertIsString($exception->getMessage());
56 }
57
61 public function testToString(int $code): void
62 {
63 $class_name = $this->getClassName();
64 $exception = new $class_name($code, 'Additional Info');
65 $this->assertIsString($exception->__toString());
66 }
67}
testConstruct(int $code)
@dataProvider codesProvider
testToString(int $code)
@dataProvider codesProvider
testAssignMessageToCode(int $code)
@dataProvider codesProvider