ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilCertificateBaseTestCase Class Reference
+ Inheritance diagram for ilCertificateBaseTestCase:
+ Collaboration diagram for ilCertificateBaseTestCase:

Protected Member Functions

 setUp ()
 
 tearDown ()
 
 assertDoesNotThrow (callable $cb, string $message='')
 
 assertThrows (callable $cb, ?string $expected_class=null, ?string $expected_message=null)
 @template T of Throwable More...
 
 setGlobalVariable (string $name, mixed $value)
 

Protected Attributes

Container $dic
 

Detailed Description

Definition at line 24 of file ilCertificateBaseTestCase.php.

Member Function Documentation

◆ assertDoesNotThrow()

ilCertificateBaseTestCase::assertDoesNotThrow ( callable  $cb,
string  $message = '' 
)
protected
Parameters
callable()void $cb

Definition at line 55 of file ilCertificateBaseTestCase.php.

55 : void
56 {
57 try {
58 $cb();
59 $this->addToAssertionCount(1);
60 } catch (Throwable $e) {
61 $this->fail(
62 trim($message . ' ' . sprintf(
63 '(unexpected %s: %s)' . PHP_EOL . '%s',
64 get_class($e),
65 $e->getMessage(),
66 $e->getTraceAsString()
67 ))
68 );
69 }
70 }
$message
Definition: xapiexit.php:31

References Vendor\Package\$e, and $message.

◆ assertThrows()

ilCertificateBaseTestCase::assertThrows ( callable  $cb,
?string  $expected_class = null,
?string  $expected_message = null 
)
protected

@template T of Throwable

Parameters
callable$cb
class-string<T>|null$expected_class
string | null$expected_message

Definition at line 78 of file ilCertificateBaseTestCase.php.

82 : void {
83 try {
84 $cb();
85 $this->fail(sprintf(
86 'Failed asserting that exception %s was thrown.',
87 $expected_class ?? '(any exception)'
88 ));
89 } catch (Throwable $e) {
90 if ($expected_class !== null && !$e instanceof $expected_class) {
91 $this->fail(sprintf(
92 'Failed asserting exception of type %s. Got %s instead.',
93 $expected_class,
94 get_class($e)
95 ));
96 }
97 if ($expected_message !== null && !str_contains($e->getMessage(), $expected_message)) {
98 $this->fail(sprintf(
99 'Failed asserting exception message contains "%s". Actual message: "%s"',
100 $expected_message,
101 $e->getMessage()
102 ));
103 }
104 $this->addToAssertionCount(1);
105 }
106 }

◆ setGlobalVariable()

ilCertificateBaseTestCase::setGlobalVariable ( string  $name,
mixed  $value 
)
protected

Definition at line 108 of file ilCertificateBaseTestCase.php.

108 : void
109 {
110 global $DIC;
111
112 $GLOBALS[$name] = $value;
113
114 unset($DIC[$name]);
115 $DIC[$name] = static function (Container $c) use ($name) {
116 return $GLOBALS[$name];
117 };
118 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
$c
Definition: deliver.php:25
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54

References $c, $DIC, and $GLOBALS.

Referenced by ilCertificateDateHelperTest\setUp().

+ Here is the caller graph for this function:

◆ setUp()

ilCertificateBaseTestCase::setUp ( )
protected

Reimplemented in ilApiUserCertificateRepositoryTest, ilCertificateDateHelperTest, ilCertificateTypeClassMapTest, and ilScormPlaceholderValuesTest.

Definition at line 28 of file ilCertificateBaseTestCase.php.

28 : void
29 {
30 if (!defined('ANONYMOUS_USER_ID')) {
31 define('ANONYMOUS_USER_ID', 13);
32 }
33
34 global $DIC;
35
36 $this->dic = is_object($DIC) ? clone $DIC : $DIC;
37
38 $DIC = new Container();
39
40 parent::setUp();
41 }

References $DIC.

◆ tearDown()

ilCertificateBaseTestCase::tearDown ( )
protected

Reimplemented in ilCertificateDateHelperTest.

Definition at line 43 of file ilCertificateBaseTestCase.php.

43 : void
44 {
45 global $DIC;
46
48
49 parent::tearDown();
50 }

References $DIC, and $dic.

Field Documentation

◆ $dic


The documentation for this class was generated from the following file: