ILIAS  release_8 Revision v8.24
ilStudyProgrammeGUIMessagesTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use PHPUnit\Framework\TestCase;
22
23class ilStudyProgrammeGUIMessagesTest extends TestCase
24{
26 protected string $topic;
27
28 public function setUp(): void
29 {
30 $collection = new ilPRGMessageCollection();
31 $lng = $this->createMock(ilLanguage::class);
32 $tpl = $this->createMock(ilGlobalTemplateInterface::class);
33 $this->messages = new ilPRGMessagePrinter($collection, $lng, $tpl);
34 $this->topic = 'a test topic';
35
36 $this->collection = $this->messages->getMessageCollection($this->topic);
37 $this->collection2 = $this->messages->getMessageCollection($this->topic);
38 }
39
40 public function testMessageFactory(): void
41 {
42 $this->assertInstanceOf(ilPRGMessageCollection::class, $this->collection);
43 $this->assertEquals($this->collection, $this->collection2);
44 $this->assertNotSame($this->collection, $this->collection2);
45 }
46
47 public function testCollectionDefaults(): void
48 {
49 $this->assertEquals($this->topic, $this->collection->getDescription());
50
51 $this->assertFalse($this->collection->hasErrors());
52 $this->assertEquals([], $this->collection->getErrors());
53
54 $this->assertFalse($this->collection->hasSuccess());
55 $this->assertEquals([], $this->collection->getSuccess());
56
57 $this->assertFalse($this->collection->hasAnyMessages());
58 }
59
60 public function testAddMessages(): void
61 {
62 $ok_message = 'looks good';
63 $ok_id = 'some good record';
64 $this->collection->add(true, $ok_message, $ok_id);
65
66 $this->assertTrue($this->collection->hasAnyMessages());
67
68 $this->assertFalse($this->collection->hasErrors());
69 $this->assertEquals([], $this->collection->getErrors());
70
71 $this->assertTrue($this->collection->hasSuccess());
72 $this->assertEquals(
73 [[$ok_message, $ok_id]],
74 $this->collection->getSuccess()
75 );
76 }
77
78 public function testAddErrorMessages(): void
79 {
80 $message = 'looks bad';
81 $id = 'some record';
82
83 $this->assertFalse($this->collection->hasAnyMessages());
84 $collection = $this->collection->withNewTopic($this->topic);
85 $this->assertFalse($collection->hasAnyMessages());
86
87 $collection->add(false, $message, $id);
88 $collection->add(false, $message, $id);
89
90 $this->assertTrue($collection->hasAnyMessages());
91
92 $this->assertTrue($collection->hasErrors());
93 $this->assertEquals(
94 [[$message, $id],[$message, $id]],
95 $collection->getErrors()
96 );
97
98 $this->assertEquals([], $collection->getSuccess());
99 $this->assertFalse($collection->hasSuccess());
100 }
101}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$lng
$message
Definition: xapiexit.php:32