ILIAS  release_8 Revision v8.24
ilTimingAcceptedTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
19use PHPUnit\Framework\TestCase;
21
26class ilTimingAcceptedTest extends TestCase
27{
28 protected Container $dic;
29
30 protected function setUp(): void
31 {
32 parent::setUp();
33 $this->initDependencies();
34 }
35
36 public function testAcceptance(): void
37 {
38 $user_id = -1;
39 $course_id = -2;
40 $acc = new ilTimingAccepted($course_id, $user_id);
41 $this->assertInstanceOf(ilTimingAccepted::class, $acc);
42 $this->assertEquals($user_id, $acc->getUserId());
43 $this->assertEquals($course_id, $acc->getCourseId());
44 $this->assertFalse($acc->isAccepted());
45 $this->assertFalse($acc->isVisible());
46 $this->assertEmpty($acc->getRemark());
47
48 $acc->setRemark('remark');
49 $acc->setVisible(true);
50 $acc->accept(true);
51
52 $this->assertTrue($acc->isAccepted());
53 $this->assertTrue($acc->isVisible());
54 $this->assertEquals('remark', $acc->getRemark());
55 }
56
57 protected function setGlobalVariable(string $name, $value): void
58 {
59 global $DIC;
60
61 $GLOBALS[$name] = $value;
62 unset($DIC[$name]);
63 $DIC[$name] = static function (\ILIAS\DI\Container $c) use ($value) {
64 return $value;
65 };
66 }
67
68 protected function initDependencies(): void
69 {
70 $this->dic = new Container();
71 $GLOBALS['DIC'] = $this->dic;
72 $this->setGlobalVariable('ilDB', $this->createMock(ilDBInterface::class));
73 }
74}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
Class ilTimingAcceptedTest.
setGlobalVariable(string $name, $value)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247