ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCoursePlaceholderDescriptionTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
7{
9 {
10 $languageMock = $this->getMockBuilder('ilLanguage')
11 ->disableOriginalConstructor()
12 ->onlyMethods(['txt', 'loadLanguageModule'])
13 ->getMock();
14
15 $templateMock = $this->getMockBuilder('ilTemplate')
16 ->disableOriginalConstructor()
17 ->getMock();
18
19 $templateMock->method('get')
20 ->willReturn('');
21
22 $userDefinePlaceholderMock = $this->getMockBuilder('ilUserDefinedFieldsPlaceholderDescription')
23 ->disableOriginalConstructor()
24 ->getMock();
25
26 $userDefinePlaceholderMock->method('createPlaceholderHtmlDescription')
27 ->willReturn('');
28
29 $userDefinePlaceholderMock->method('getPlaceholderDescriptions')
30 ->willReturn([]);
31
32 $customUserPlaceholderObject = $this->getMockBuilder("ilObjectCustomUserFieldsPlaceholderDescription")
33 ->disableOriginalConstructor()
34 ->getMock();
35
36 $customUserPlaceholderObject->method("getPlaceholderDescriptions")
37 ->willReturn(array(
38 '+SOMETHING' => 'SOMEWHAT',
39 '+SOMETHING_ELSE' => 'ANYTHING'
40 ));
41
42 $customUserPlaceholderObject->method('createPlaceholderHtmlDescription')
43 ->willReturn('');
44
45 $placeholderDescriptionObject = new ilCoursePlaceholderDescription(200, null, $languageMock, $userDefinePlaceholderMock, $customUserPlaceholderObject);
46
47 $html = $placeholderDescriptionObject->createPlaceholderHtmlDescription($templateMock);
48
49 $this->assertEquals('', $html);
50 }
51
53 {
54 $languageMock = $this->getMockBuilder('ilLanguage')
55 ->disableOriginalConstructor()
56 ->onlyMethods(['txt'])
57 ->getMock();
58
59 $languageMock->expects($this->exactly(3))
60 ->method('txt')
61 ->willReturn('Something translated');
62
63 $defaultPlaceholder = $this->getMockBuilder('ilDefaultPlaceholderDescription')
64 ->disableOriginalConstructor()
65 ->getMock();
66
67 $defaultPlaceholder->method('getPlaceholderDescriptions')
68 ->willReturn(
69 array(
70 'SOMETHING' => 'SOMEWHAT',
71 'SOMETHING_ELSE' => 'ANYTHING'
72 )
73 );
74
75 $customUserPlaceholderObject = $this->getMockBuilder('ilObjectCustomUserFieldsPlaceholderDescription')
76 ->disableOriginalConstructor()
77 ->getMock();
78
79 $customUserPlaceholderObject->method('getPlaceholderDescriptions')
80 ->willReturn(
81 array(
82 '+SOMETHING' => 'SOMEWHAT',
83 '+SOMETHING_ELSE' => 'ANYTHING'
84 )
85 );
86
87 $placeholderDescriptionObject = new ilCoursePlaceholderDescription(200, $defaultPlaceholder, $languageMock, null, $customUserPlaceholderObject);
88
89 $placeHolders = $placeholderDescriptionObject->getPlaceholderDescriptions();
90
91 $this->assertEquals(
92 array(
93 'COURSE_TITLE' => 'Something translated',
94 'SOMETHING' => 'SOMEWHAT',
95 'SOMETHING_ELSE' => 'ANYTHING',
96 '+SOMETHING' => 'SOMEWHAT',
97 '+SOMETHING_ELSE' => 'ANYTHING',
98 'DATE_COMPLETED' => 'Something translated',
99 'DATETIME_COMPLETED' => 'Something translated'
100 ),
101 $placeHolders
102 );
103 }
104}
An exception for terminatinating execution or to throw for unit testing.
Class ilCertificateBaseTestCase.