ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPdfGeneratorTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
29 {
33  public function testGenerateSpecificCertificate(): void
34  {
35  if (!defined('CLIENT_WEB_DIR')) {
36  define('CLIENT_WEB_DIR', 'my/client/web/dir');
37  }
38  $certificate = new ilUserCertificate(
39  3,
40  20,
41  'crs',
42  50,
43  'ilyas',
44  123_456_789,
45  '<xml> Some content </xml>',
46  '[]',
47  null,
48  3,
49  'v5.4.0',
50  true,
51  new CertificateId('11111111-2222-3333-4444-555555555555'),
52  '/some/where/background.jpg',
53  '/some/where/tile_image.jpg',
54  '',
55  '',
56  300
57  );
58 
59  $userCertificateRepository = $this->getMockBuilder(ilUserCertificateRepository::class)
60  ->disableOriginalConstructor()
61  ->getMock()
62  ;
63 
64  $userCertificateRepository->method('fetchCertificate')
65  ->willReturn($certificate)
66  ;
67 
68  $rpcHelper = $this->getMockBuilder(ilCertificateRpcClientFactoryHelper::class)
69  ->getMock()
70  ;
71 
72  $pdf = new stdClass();
73  $pdf->scalar = '';
74  $rpcHelper->method('ilFO2PDF')
75  ->willReturn($pdf)
76  ;
77 
78  $pdfFileNameFactory = $this->getMockBuilder(ilCertificatePdfFileNameFactory::class)
79  ->disableOriginalConstructor()
80  ->getMock()
81  ;
82 
83  $language = $this->getMockBuilder(ilLanguage::class)
84  ->disableOriginalConstructor()
85  ->getMock()
86  ;
87 
88  $irss = $this->getMockBuilder(IRSS::class)
89  ->disableOriginalConstructor()
90  ->getMock()
91  ;
92 
93  $filesystem = $this->getMockBuilder(Filesystem::class)
94  ->disableOriginalConstructor()
95  ->getMock();
96 
97  $pdfGenerator = new ilPdfGenerator(
98  $userCertificateRepository,
99  $irss,
100  $filesystem,
101  $rpcHelper,
102  $pdfFileNameFactory,
103  $language
104  );
105 
106  $pdfGenerator->generate(100);
107  }
108 
112  public function testGenerateCurrentActiveCertificate(): void
113  {
114  if (!defined('CLIENT_WEB_DIR')) {
115  define('CLIENT_WEB_DIR', 'my/client/web/dir');
116  }
117  $certificate = new ilUserCertificate(
118  3,
119  20,
120  'crs',
121  50,
122  'ilyas',
123  123_456_789,
124  '<xml> Some content </xml>',
125  '[]',
126  null,
127  3,
128  'v5.4.0',
129  true,
130  new CertificateId('11111111-2222-3333-4444-555555555555'),
131  '/some/where/background.jpg',
132  '/some/where/tile_image.jpg',
133  '',
134  '',
135  300
136  );
137 
138  $userCertificateRepository = $this->getMockBuilder(ilUserCertificateRepository::class)
139  ->disableOriginalConstructor()
140  ->getMock()
141  ;
142 
143  $userCertificateRepository->method('fetchActiveCertificate')
144  ->willReturn($certificate)
145  ;
146 
147  $rpcHelper = $this->getMockBuilder(ilCertificateRpcClientFactoryHelper::class)
148  ->getMock()
149  ;
150 
151  $pdf = new stdClass();
152  $pdf->scalar = '';
153  $rpcHelper->method('ilFO2PDF')
154  ->willReturn($pdf)
155  ;
156 
157  $pdfFileNameFactory = $this->getMockBuilder(ilCertificatePdfFileNameFactory::class)
158  ->disableOriginalConstructor()
159  ->getMock()
160  ;
161 
162  $language = $this->getMockBuilder(ilLanguage::class)
163  ->disableOriginalConstructor()
164  ->getMock()
165  ;
166 
167  $irss = $this->getMockBuilder(IRSS::class)
168  ->disableOriginalConstructor()
169  ->getMock()
170  ;
171 
172  $filesystem = $this->getMockBuilder(Filesystem::class)
173  ->disableOriginalConstructor()
174  ->getMock();
175 
176  $pdfGenerator = new ilPdfGenerator(
177  $userCertificateRepository,
178  $irss,
179  $filesystem,
180  $rpcHelper,
181  $pdfFileNameFactory,
182  $language
183  );
184 
185  $pdfGenerator->generateCurrentActiveCertificate(100, 200);
186  }
187 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCertificateBaseTestCase.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...