ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilScormPlaceholderDescriptionTest.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  $objectMock = $this->getMockBuilder('ilObject')
11  ->disableOriginalConstructor()
12  ->setMethods(array('txt'))
13  ->getMock();
14 
15  $languageMock = $this->getMockBuilder('ilLanguage')
16  ->disableOriginalConstructor()
17  ->setMethods(array('txt'))
18  ->getMock();
19 
20  $templateMock = $this->getMockBuilder('ilTemplate')
21  ->disableOriginalConstructor()
22  ->getMock();
23 
24  $templateMock->method('get')
25  ->willReturn('');
26 
27  $collectionInstance = $this->getMockBuilder('ilLPCollection')
28  ->disableOriginalConstructor()
29  ->setMethods(array('getPossibleItems'))
30  ->getMock();
31 
32  $learningProgressMock = $this->getMockBuilder('ilObjectLP')
33  ->disableOriginalConstructor()
34  ->setMethods(array('getCollectionInstance'))
35  ->getMock();
36 
37  $collectionInstance->method('getPossibleItems')
38  ->willReturn(array(0 => array('title' => 'Some SCORM Title')));
39 
40  $learningProgressMock->method('getCollectionInstance')
41  ->willReturn($collectionInstance);
42 
43  $userDefinePlaceholderMock = $this->getMockBuilder('ilUserDefinedFieldsPlaceholderDescription')
44  ->disableOriginalConstructor()
45  ->getMock();
46 
47  $userDefinePlaceholderMock->method('createPlaceholderHtmlDescription')
48  ->willReturn(array());
49 
50  $userDefinePlaceholderMock->method('getPlaceholderDescriptions')
51  ->willReturn(array());
52 
53  $placeholderDescriptionObject = new ilScormPlaceholderDescription(
54  $objectMock,
55  null,
56  $languageMock,
57  $learningProgressMock,
58  $userDefinePlaceholderMock
59  );
60 
61  $html = $placeholderDescriptionObject->createPlaceholderHtmlDescription($templateMock);
62 
63  $this->assertEquals('', $html);
64  }
65 
66  public function testPlaceholderDescriptions()
67  {
68  $objectMock = $this->getMockBuilder('ilObject')
69  ->disableOriginalConstructor()
70  ->setMethods(array('txt'))
71  ->getMock();
72 
73  $languageMock = $this->getMockBuilder('ilLanguage')
74  ->disableOriginalConstructor()
75  ->setMethods(array('txt'))
76  ->getMock();
77 
78  $languageMock->expects($this->exactly(21))
79  ->method('txt')
80  ->willReturn('Something translated');
81 
82  $learningProgressMock = $this->getMockBuilder('ilObjectLP')
83  ->disableOriginalConstructor()
84  ->setMethods(array('getCollectionInstance'))
85  ->getMock();
86 
87  $userDefinePlaceholderMock = $this->getMockBuilder('ilUserDefinedFieldsPlaceholderDescription')
88  ->disableOriginalConstructor()
89  ->getMock();
90 
91  $userDefinePlaceholderMock->method('createPlaceholderHtmlDescription')
92  ->willReturn(array());
93 
94  $userDefinePlaceholderMock->method('getPlaceholderDescriptions')
95  ->willReturn(array());
96 
97  $placeholderDescriptionObject = new ilScormPlaceholderDescription(
98  $objectMock,
99  null,
100  $languageMock,
101  $learningProgressMock,
102  $userDefinePlaceholderMock
103  );
104 
105  $placeHolders = $placeholderDescriptionObject->getPlaceholderDescriptions();
106 
107  $this->assertEquals(
108  array(
109  'USER_LOGIN' => 'Something translated',
110  'USER_FULLNAME' => 'Something translated',
111  'USER_FIRSTNAME' => 'Something translated',
112  'USER_LASTNAME' => 'Something translated',
113  'USER_TITLE' => 'Something translated',
114  'USER_SALUTATION' => 'Something translated',
115  'USER_BIRTHDAY' => 'Something translated',
116  'USER_INSTITUTION' => 'Something translated',
117  'USER_DEPARTMENT' => 'Something translated',
118  'USER_STREET' => 'Something translated',
119  'USER_CITY' => 'Something translated',
120  'USER_ZIPCODE' => 'Something translated',
121  'USER_COUNTRY' => 'Something translated',
122  'USER_MATRICULATION' => 'Something translated',
123  'DATE' => 'Something translated',
124  'DATETIME' => 'Something translated',
125  'SCORM_TITLE' => 'Something translated',
126  'SCORM_POINTS' => 'Something translated',
127  'SCORM_POINTS_MAX' => 'Something translated',
128  'DATE_COMPLETED' => 'Something translated',
129  'DATETIME_COMPLETED' => 'Something translated'
130  ),
131  $placeHolders
132  );
133  }
134 }
$html
Definition: example_001.php:87