ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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::class)
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15  $placeholderValuesObject = $this->getMockBuilder(ilCertificatePlaceholderValues::class)
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::class)
27  ->disableOriginalConstructor()
28  ->getMock();
29 
30  $user = $this->getMockBuilder(ilObjUser::class)
31  ->disableOriginalConstructor()
32  ->getMock();
33 
34  $pdfFileNameFactory = $this->getMockBuilder(ilCertificatePdfFileNameFactory::class)
35  ->disableOriginalConstructor()
36  ->getMock();
37  $pdfFileNameFactory
38  ->expects($this->once())
39  ->method('create')
40  ->willReturn('test');
41 
42  $user->method('getId')
43  ->willReturn(100);
44 
45  $utilHelper = $this->getMockBuilder(ilCertificateUtilHelper::class)
46  ->getMock();
47 
48  $utilHelper
49  ->expects($this->once())
50  ->method('deliverData');
51 
52  $mathJaxHelper = $this->getMockBuilder(ilCertificateMathJaxHelper::class)
53  ->getMock();
54 
55  $mathJaxHelper->method('fillXlsFoContent')
56  ->willReturn('<xml> Some filled XML content </xml>');
57 
58  $userDefinedFieldsHelper = $this->getMockBuilder(ilCertificateUserDefinedFieldsHelper::class)
59  ->getMock();
60 
61  $definitionsMock = $this->getMockBuilder(ilUserDefinedFields::class)
62  ->disableOriginalConstructor()
63  ->getMock();
64 
65  $definitionsMock->method('getDefinitions')
66  ->willReturn(
67  array(
68  'f_1' => array(
69  'certificate' => true,
70  'field_id' => 100,
71  'field_name' => 'Some Field Name',
72  )
73  )
74  );
75 
76  $userDefinedFieldsHelper->method('createInstance')
77  ->willReturn($definitionsMock);
78 
79  $rpcClientFactoryHelper = $this->getMockBuilder(ilCertificateRpcClientFactoryHelper::class)
80  ->getMock();
81 
82  $mock = $this->getMockBuilder(stdClass::class)
83  ->disableOriginalConstructor()
84  ->getMock();
85 
86  $mock->scalar = '<xml> Some XML content </xml>';
87 
88  $rpcClientFactoryHelper->method('ilFO2PDF')
89  ->willReturn($mock);
90 
91 
92 
93  $previewAction = new ilCertificateTemplatePreviewAction(
94  $templateRepository,
95  $placeholderValuesObject,
96  $logger,
97  $user,
98  $utilHelper,
99  $mathJaxHelper,
100  $userDefinedFieldsHelper,
101  $rpcClientFactoryHelper,
102  'some/where/',
103  $pdfFileNameFactory
104  );
105 
106  $previewAction->createPreviewPdf(100);
107  }
108 }
Class ilCertificateBaseTestCase.