23 : 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 '-',
58 '-',
59 null
60 ),
62 20,
63 'crs',
64 '<xml> Some Content </xml>',
65 md5('<xml> Some Content </xml>'),
66 '[]',
67 3,
68 'v5.3.0',
69 123_456_789,
70 true,
71 '-',
72 '-',
73 null
74 ),
76 30,
77 'crs',
78 '<xml> Some Content </xml>',
79 md5('<xml> Some Content </xml>'),
80 '[]',
81 3,
82 'v5.3.0',
83 123_456_789,
84 true,
85 '-',
86 '-',
87 null
88 )
89 ]
90 );
91
92 $templateRepository
93 ->expects($this->exactly(3))
94 ->method('save');
95
96 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
97 ->getMock();
98
99 $objectHelper->method('lookupObjId')
100 ->willReturn(1000);
101 $objectHelper->method('lookupType')
102 ->willReturn('crs');
103
104 $global_certificate_settings = $this->getMockBuilder(ilObjCertificateSettings::class)
105 ->disableOriginalConstructor()
106 ->getMock();
107
109 $database,
111 $templateRepository,
112 $objectHelper,
113 $global_certificate_settings
114 );
115
116 $oldObject = $this->getMockBuilder(ilObject::class)
117 ->disableOriginalConstructor()
118 ->getMock();
119
120 $oldObject->method('getType')
121 ->willReturn('crs');
122
123 $oldObject->method('getId')
124 ->willReturn(10);
125
126 $newObject = $this->getMockBuilder(ilObject::class)
127 ->disableOriginalConstructor()
128 ->getMock();
129
130 $newObject->method('getType')
131 ->willReturn('crs');
132
133 $newObject->method('getId')
134 ->willReturn(10);
135
136 $cloneAction->cloneCertificate($oldObject, $newObject, 'v5.4.0', '/some/web/dir');
137 }