ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCertificateCloneActionTest.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 testCloneCertificate()
10  {
11  $database = $this->getMockBuilder('ilDBInterface')
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15  $database
16  ->expects($this->once())
17  ->method('query');
18 
19  $database
20  ->expects($this->once())
21  ->method('numRows')
22  ->willReturn(1);
23 
24  $database
25  ->expects($this->once())
26  ->method('replace');
27 
28 
29 
30  $templateRepository = $this->getMockBuilder('ilCertificateTemplateRepository')
31  ->disableOriginalConstructor()
32  ->getMock();
33 
34  $templateRepository->method('fetchCertificateTemplatesByObjId')
35  ->willReturn(
36  array(
38  10,
39  'crs',
40  '<xml> Some Content </xml>',
41  md5('<xml> Some Content </xml>'),
42  '[]',
43  '3',
44  'v5.3.0',
45  123456789,
46  true,
47  '/some/where/background.jpg',
48  '/some/where/card_thumb.jpg',
49  $id = null
50  ),
52  20,
53  'crs',
54  '<xml> Some Content </xml>',
55  md5('<xml> Some Content </xml>'),
56  '[]',
57  '3',
58  'v5.3.0',
59  123456789,
60  true,
61  '/some/where/background.jpg',
62  '/some/where/card_thumb.jpg',
63  $id = null
64  ),
66  30,
67  'crs',
68  '<xml> Some Content </xml>',
69  md5('<xml> Some Content </xml>'),
70  '[]',
71  '3',
72  'v5.3.0',
73  123456789,
74  true,
75  '/certificates/default/background.jpg',
76  '/some/where/card_thumb.jpg',
77  $id = null
78  )
79  )
80  );
81 
82  $templateRepository
83  ->expects($this->exactly(3))
84  ->method('save');
85 
86  $fileSystem = $this->getMockBuilder('\ILIAS\Filesystem\Filesystem')
87  ->getMock();
88 
89  $fileSystem->method('has')
90  ->willReturn(true);
91 
92  $fileSystem
93  ->expects($this->exactly(7))
94  ->method('copy');
95 
96  $logger = $this->getMockBuilder('ilLogger')
97  ->disableOriginalConstructor()
98  ->getMock();
99 
100  $objectHelper = $this->getMockBuilder('ilCertificateObjectHelper')
101  ->getMock();
102 
103  $objectHelper->method('lookupObjId')
104  ->willReturn(1000);
105 
106  $global_certificate_settings = $this->getMockBuilder(ilObjCertificateSettings::class)
107  ->disableOriginalConstructor()
108  ->getMock();
109 
110 
111  $cloneAction = new ilCertificateCloneAction(
112  $database,
114  $templateRepository,
115  $fileSystem,
116  $logger,
117  $objectHelper,
118  $global_certificate_settings,
119  'some/web/directory',
120  '/certificates/default/background.jpg'
121  );
122 
123  $oldObject = $this->getMockBuilder('ilObject')
124  ->disableOriginalConstructor()
125  ->getMock();
126 
127  $oldObject->method('getType')
128  ->willReturn('crs');
129 
130  $oldObject->method('getId')
131  ->willReturn(10);
132 
133  $newObject = $this->getMockBuilder('ilObject')
134  ->disableOriginalConstructor()
135  ->getMock();
136 
137  $newObject->method('getType')
138  ->willReturn('crs');
139 
140  $newObject->method('getId')
141  ->willReturn(10);
142 
143  $cloneAction->cloneCertificate($oldObject, $newObject, 'v5.4.0', '/some/web/dir');
144  }
145 }
Class ilCertificateBaseTestCase.