ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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  ->setMethods(array('txt'))
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(array());
28 
29  $userDefinePlaceholderMock->method('getPlaceholderDescriptions')
30  ->willReturn(array());
31 
32  $placeholderDescriptionObject = new ilCoursePlaceholderDescription(null, $languageMock, $userDefinePlaceholderMock);
33 
34  $html = $placeholderDescriptionObject->createPlaceholderHtmlDescription($templateMock);
35 
36  $this->assertEquals('', $html);
37  }
38 
39  public function testPlaceholderDescriptions()
40  {
41  $languageMock = $this->getMockBuilder('ilLanguage')
42  ->disableOriginalConstructor()
43  ->setMethods(array('txt'))
44  ->getMock();
45 
46  $languageMock->expects($this->exactly(3))
47  ->method('txt')
48  ->willReturn('Something translated');
49 
50  $defaultPlaceholder = $this->getMockBuilder('ilDefaultPlaceholderDescription')
51  ->disableOriginalConstructor()
52  ->getMock();
53 
54  $defaultPlaceholder->method('getPlaceholderDescriptions')
55  ->willReturn(
56  array(
57  'SOMETHING' => 'SOMEWHAT',
58  'SOMETHING_ELSE' => 'ANYTHING'
59  )
60  );
61 
62  $placeholderDescriptionObject = new ilCoursePlaceholderDescription($defaultPlaceholder, $languageMock);
63 
64  $placeHolders = $placeholderDescriptionObject->getPlaceholderDescriptions();
65 
66  $this->assertEquals(
67  array(
68  'COURSE_TITLE' => 'Something translated',
69  'SOMETHING' => 'SOMEWHAT',
70  'SOMETHING_ELSE' => 'ANYTHING',
71  'DATE_COMPLETED' => 'Something translated',
72  'DATETIME_COMPLETED' => 'Something translated'
73  ),
74  $placeHolders
75  );
76  }
77 }
$html
Definition: example_001.php:87