ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilCertificateCloneActionTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 {
23  public function testCloneCertificate(): void
24  {
25  $database = $this->createMock(ilDBInterface::class);
26 
27  $database
28  ->expects($this->once())
29  ->method('query');
30 
31  $database
32  ->expects($this->once())
33  ->method('fetchAssoc')
34  ->willReturn(['1' => '1']);
35 
36  $database
37  ->expects($this->once())
38  ->method('replace');
39 
40 
41 
42  $templateRepository = $this->getMockBuilder(ilCertificateTemplateRepository::class)->getMock();
43 
44  $templateRepository->method('fetchCertificateTemplatesByObjId')
45  ->willReturn(
46  [
48  10,
49  'crs',
50  '<xml> Some Content </xml>',
51  md5('<xml> Some Content </xml>'),
52  '[]',
53  3,
54  'v5.3.0',
55  123_456_789,
56  true,
57  '/some/where/background.jpg',
58  '/some/where/card_tile_image.jpg',
59  '-',
60  '-',
61  null
62  ),
64  20,
65  'crs',
66  '<xml> Some Content </xml>',
67  md5('<xml> Some Content </xml>'),
68  '[]',
69  3,
70  'v5.3.0',
71  123_456_789,
72  true,
73  '/some/where/background.jpg',
74  '/some/where/card_tile_image.jpg',
75  '-',
76  '-',
77  null
78  ),
80  30,
81  'crs',
82  '<xml> Some Content </xml>',
83  md5('<xml> Some Content </xml>'),
84  '[]',
85  3,
86  'v5.3.0',
87  123_456_789,
88  true,
89  '/certificates/default/background.jpg',
90  '/some/where/card_tile_image.jpg',
91  '-',
92  '-',
93  null
94  )
95  ]
96  );
97 
98  $templateRepository
99  ->expects($this->exactly(3))
100  ->method('save');
101 
102  $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
103  ->getMock();
104 
105  $objectHelper->method('lookupObjId')
106  ->willReturn(1000);
107 
108  $global_certificate_settings = $this->getMockBuilder(ilObjCertificateSettings::class)
109  ->disableOriginalConstructor()
110  ->getMock();
111 
112  $cloneAction = new ilCertificateCloneAction(
113  $database,
115  $templateRepository,
116  $objectHelper,
117  $global_certificate_settings
118  );
119 
120  $oldObject = $this->getMockBuilder(ilObject::class)
121  ->disableOriginalConstructor()
122  ->getMock();
123 
124  $oldObject->method('getType')
125  ->willReturn('crs');
126 
127  $oldObject->method('getId')
128  ->willReturn(10);
129 
130  $newObject = $this->getMockBuilder(ilObject::class)
131  ->disableOriginalConstructor()
132  ->getMock();
133 
134  $newObject->method('getType')
135  ->willReturn('crs');
136 
137  $newObject->method('getId')
138  ->willReturn(10);
139 
140  $cloneAction->cloneCertificate($oldObject, $newObject, 'v5.4.0', '/some/web/dir');
141  }
142 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null