ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 )
65 )
66 );
67
68 $templateRepository
69 ->expects($this->exactly(2))
70 ->method('save');
71
72 $fileSystem = $this->getMockBuilder('\ILIAS\Filesystem\Filesystem')
73 ->getMock();
74
75 $fileSystem->method('has')
76 ->willReturn(true);
77
78 $fileSystem
79 ->expects($this->exactly(6))
80 ->method('copy');
81
82 $logger = $this->getMockBuilder('ilLogger')
83 ->disableOriginalConstructor()
84 ->getMock();
85
86 $objectHelper = $this->getMockBuilder('ilCertificateObjectHelper')
87 ->getMock();
88
89 $objectHelper->method('lookupObjId')
90 ->willReturn(1000);
91
92 $cloneAction = new ilCertificateCloneAction(
93 $database,
95 $templateRepository,
96 $fileSystem,
97 $logger,
98 $objectHelper,
99 'some/web/directory'
100 );
101
102 $oldObject = $this->getMockBuilder('ilObject')
103 ->disableOriginalConstructor()
104 ->getMock();
105
106 $oldObject->method('getType')
107 ->willReturn('crs');
108
109 $oldObject->method('getId')
110 ->willReturn(10);
111
112 $newObject = $this->getMockBuilder('ilObject')
113 ->disableOriginalConstructor()
114 ->getMock();
115
116 $newObject->method('getType')
117 ->willReturn('crs');
118
119 $newObject->method('getId')
120 ->willReturn(10);
121
122 $cloneAction->cloneCertificate($oldObject, $newObject, 'v5.4.0', '/some/web/dir');
123 }
124}
An exception for terminatinating execution or to throw for unit testing.
Class ilCertificateBaseTestCase.