ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateTemplatePreviewActionTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
9  public function testA()
10  {
11  $templateRepository = $this->getMockBuilder('ilCertificateTemplateRepository')
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15  $placeholderValuesObject = $this->getMockBuilder('ilCertificatePlaceholderValues')
16  ->disableOriginalConstructor()
17  ->getMock();
18 
19  $placeholderValuesObject->method('getPlaceholderValuesForPreview')
20  ->willReturn(array(
21  'USER_LOGIN' => 'SomeLogin',
22  'USER_FULLNAME' => 'SomeFullName',
23  'USER_FIRSTNAME' => 'SomeFirstName'
24  ));
25 
26  $logger = $this->getMockBuilder('ilLogger')
27  ->disableOriginalConstructor()
28  ->getMock();
29 
30  $user = $this->getMockBuilder('ilObjUser')
31  ->disableOriginalConstructor()
32  ->getMock();
33 
34  $user->method('getId')
35  ->willReturn(100);
36 
37  $utilHelper = $this->getMockBuilder('ilCertificateUtilHelper')
38  ->getMock();
39 
40  $utilHelper
41  ->expects($this->once())
42  ->method('deliverData');
43 
44  $mathJaxHelper = $this->getMockBuilder('ilCertificateMathJaxHelper')
45  ->getMock();
46 
47  $mathJaxHelper->method('fillXlsFoContent')
48  ->willReturn('<xml> Some filled XML content </xml>');
49 
50  $userDefinedFieldsHelper = $this->getMockBuilder('ilCertificateUserDefinedFieldsHelper')
51  ->getMock();
52 
53  $definitionsMock = $this->getMockBuilder('ilUserDefinedFields')
54  ->disableOriginalConstructor()
55  ->getMock();
56 
57  $definitionsMock->method('getDefinitions')
58  ->willReturn(
59  array(
60  'f_1' => array(
61  'certificate' => true,
62  'field_id' => 100,
63  'field_name' => 'Some Field Name',
64  )
65  )
66  );
67 
68  $userDefinedFieldsHelper->method('createInstance')
69  ->willReturn($definitionsMock);
70 
71  $rpcClientFactoryHelper = $this->getMockBuilder('ilCertificateRpcClientFactoryHelper')
72  ->getMock();
73 
74  $mock = $this->getMockBuilder('StdClass')
75  ->disableOriginalConstructor()
76  ->getMock();
77 
78  $mock->scalar = '<xml> Some XML content </xml>';
79 
80  $rpcClientFactoryHelper->method('ilFO2PDF')
81  ->willReturn($mock);
82 
83 
84 
85  $previewAction = new ilCertificateTemplatePreviewAction(
86  $templateRepository,
87  $placeholderValuesObject,
88  $logger,
89  $user,
90  $utilHelper,
91  $mathJaxHelper,
92  $userDefinedFieldsHelper,
93  $rpcClientFactoryHelper,
94  'some/where/'
95  );
96 
97  $previewAction->createPreviewPdf(100);
98  }
99 }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$user
Definition: migrateto20.php:57