ILIAS  release_8 Revision v8.24
ilCertificateCloneActionTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25{
26 public function testCloneCertificate(): void
27 {
28 $database = $this->createMock(ilDBInterface::class);
29
30 $database
31 ->expects($this->once())
32 ->method('query');
33
34 $database
35 ->expects($this->once())
36 ->method('fetchAssoc')
37 ->willReturn(['1' => '1']);
38
39 $database
40 ->expects($this->once())
41 ->method('replace');
42
43
44
45 $templateRepository = $this->getMockBuilder(ilCertificateTemplateRepository::class)->getMock();
46
47 $templateRepository->method('fetchCertificateTemplatesByObjId')
48 ->willReturn(
49 [
51 10,
52 'crs',
53 '<xml> Some Content </xml>',
54 md5('<xml> Some Content </xml>'),
55 '[]',
56 3,
57 'v5.3.0',
58 123456789,
59 true,
60 '/some/where/background.jpg',
61 '/some/where/card_thumb.jpg',
62 null
63 ),
65 20,
66 'crs',
67 '<xml> Some Content </xml>',
68 md5('<xml> Some Content </xml>'),
69 '[]',
70 3,
71 'v5.3.0',
72 123456789,
73 true,
74 '/some/where/background.jpg',
75 '/some/where/card_thumb.jpg',
76 null
77 ),
79 30,
80 'crs',
81 '<xml> Some Content </xml>',
82 md5('<xml> Some Content </xml>'),
83 '[]',
84 3,
85 'v5.3.0',
86 123456789,
87 true,
88 '/certificates/default/background.jpg',
89 '/some/where/card_thumb.jpg',
90 null
91 )
92 ]
93 );
94
95 $templateRepository
96 ->expects($this->exactly(3))
97 ->method('save');
98
99 $fileSystem = $this->getMockBuilder(\ILIAS\Filesystem\Filesystem::class)
100 ->getMock();
101
102 $fileSystem->method('has')
103 ->willReturn(true);
104
105 $fileSystem
106 ->expects($this->exactly(7))
107 ->method('copy');
108
109 $logger = $this->getMockBuilder(ilLogger::class)
110 ->disableOriginalConstructor()
111 ->getMock();
112
113 $objectHelper = $this->getMockBuilder(ilCertificateObjectHelper::class)
114 ->getMock();
115
116 $objectHelper->method('lookupObjId')
117 ->willReturn(1000);
118
119 $global_certificate_settings = $this->getMockBuilder(ilObjCertificateSettings::class)
120 ->disableOriginalConstructor()
121 ->getMock();
122
123 $cloneAction = new ilCertificateCloneAction(
124 $database,
126 $templateRepository,
127 $fileSystem,
128 $logger,
129 $objectHelper,
130 $global_certificate_settings,
131 'some/web/directory',
132 '/certificates/default/background.jpg'
133 );
134
135 $oldObject = $this->getMockBuilder(ilObject::class)
136 ->disableOriginalConstructor()
137 ->getMock();
138
139 $oldObject->method('getType')
140 ->willReturn('crs');
141
142 $oldObject->method('getId')
143 ->willReturn(10);
144
145 $newObject = $this->getMockBuilder(ilObject::class)
146 ->disableOriginalConstructor()
147 ->getMock();
148
149 $newObject->method('getType')
150 ->willReturn('crs');
151
152 $newObject->method('getId')
153 ->willReturn(10);
154
155 $cloneAction->cloneCertificate($oldObject, $newObject, 'v5.4.0', '/some/web/dir');
156 }
157}
Class ilCertificateBaseTestCase.
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...
Class ChatMainBarProvider \MainMenu\Provider.