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 $dataGatewayFactory,
34 $this->getMockBuilder(ilTermsOfServiceDocumentEvaluation::class)->getMock(),
35 $this->getMockBuilder(ilTermsOfServiceCriterionTypeFactoryInterface::class)->getMock(),
36 $this->getMockBuilder(ilObjTermsOfService::class)->disableOriginalConstructor()->getMock()
37 );
38
39 $user = $this
40 ->getMockBuilder(ilObjUser::class)
41 ->disableOriginalConstructor()
42 ->onlyMethods(['getLanguage', 'getId', 'getLogin', 'writeAccepted', 'hasToAcceptTermsOfServiceInSession'])
43 ->getMock();
44
45 $user
46 ->expects($this->any())
47 ->method('getId')
48 ->willReturn(-1);
49
50 $user
51 ->expects($this->any())
52 ->method('getLogin')
53 ->willReturn('phpunit');
54
55 $user
56 ->expects($this->once())
57 ->method('writeAccepted');
58
59 $user
60 ->expects($this->once())
61 ->method('hasToAcceptTermsOfServiceInSession')
62 ->with(false);
63
64 $document = $this
65 ->getMockBuilder(ilTermsOfServiceDocument::class)
66 ->disableOriginalConstructor()
67 ->onlyMethods(['content', 'id', 'criteria', 'title'])
68 ->getMock();
69
70 $document
71 ->expects($this->atLeast(1))
72 ->method('content')
73 ->willReturn('phpunit');
74
75 $document
76 ->expects($this->atLeast(1))
77 ->method('title')
78 ->willReturn('phpunit');
79
80 $document
81 ->expects($this->atLeast(1))
82 ->method('id')
83 ->willReturn(1);
84
85 $document
86 ->expects($this->atLeast(1))
87 ->method('criteria')
88 ->willReturn([]);
89
90 $helper->trackAcceptance($user, $document);
91 }