15 : void
16 {
17 $dataGatewayFactory = $this->getMockBuilder(ilTermsOfServiceDataGatewayFactory::class)->getMock();
18 $dataGateway = $this
19 ->getMockBuilder(ilTermsOfServiceAcceptanceDataGateway::class)
20 ->getMock();
21
22 $dataGateway
23 ->expects($this->once())
24 ->method('trackAcceptance')
25 ->with($this->isInstanceOf(ilTermsOfServiceAcceptanceEntity::class));
26
27 $dataGatewayFactory
28 ->expects($this->any())
29 ->method('getByName')
30 ->willReturn($dataGateway);
31
33 $this->getMockBuilder(ilDBInterface::class)->getMock(),
34 $dataGatewayFactory
35 );
36
37 $user = $this
38 ->getMockBuilder(ilObjUser::class)
39 ->disableOriginalConstructor()
40 ->setMethods(['getLanguage', 'getId', 'getLogin', 'writeAccepted', 'hasToAcceptTermsOfServiceInSession'])
41 ->getMock();
42
43 $user
44 ->expects($this->any())
45 ->method('getId')
46 ->willReturn(-1);
47
48 $user
49 ->expects($this->any())
50 ->method('getLogin')
51 ->willReturn('phpunit');
52
53 $user
54 ->expects($this->once())
55 ->method('writeAccepted');
56
57 $user
58 ->expects($this->once())
59 ->method('hasToAcceptTermsOfServiceInSession')
60 ->with(false);
61
62 $document = $this
63 ->getMockBuilder(ilTermsOfServiceDocument::class)
64 ->disableOriginalConstructor()
65 ->setMethods(['content', 'id', 'criteria', 'title'])
66 ->getMock();
67
68 $document
69 ->expects($this->atLeast(1))
70 ->method('content')
71 ->willReturn('phpunit');
72
73 $document
74 ->expects($this->atLeast(1))
75 ->method('title')
76 ->willReturn('phpunit');
77
78 $document
79 ->expects($this->atLeast(1))
80 ->method('id')
81 ->willReturn(1);
82
83 $document
84 ->expects($this->atLeast(1))
85 ->method('criteria')
86 ->willReturn([]);
87
88 $helper->trackAcceptance($user, $document);
89 }