ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCertificateActiveValidatorTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 class ilCertificateActiveValidatorTest extends \PHPUnit\Framework\TestCase
25 {
27  {
28  $settings = $this->getMockBuilder(ilSetting::class)
29  ->disableOriginalConstructor()
30  ->getMock();
31 
32  $settings->method('get')
33  ->with('active')
34  ->willReturn('1');
35 
36  $rpcSettings = $this->getMockBuilder(ilRPCServerSettings::class)
37  ->disableOriginalConstructor()
38  ->getMock();
39 
40  $rpcSettings->method('isEnabled')
41  ->willReturn(true);
42 
43  $validator = new ilCertificateActiveValidator($settings, $rpcSettings);
44 
45  $result = $validator->validate();
46 
47  $this->assertTrue($result);
48  }
49 
51  {
52  $settings = $this->getMockBuilder(ilSetting::class)
53  ->disableOriginalConstructor()
54  ->getMock();
55 
56  $settings->method('get')
57  ->with('active')
58  ->willReturn('0');
59 
60  $rpcSettings = $this->getMockBuilder(ilRPCServerSettings::class)
61  ->disableOriginalConstructor()
62  ->getMock();
63 
64  $rpcSettings
65  ->expects($this->never())
66  ->method('isEnabled')
67  ->willReturn(true);
68 
69  $validator = new ilCertificateActiveValidator($settings, $rpcSettings);
70 
71  $result = $validator->validate();
72 
73  $this->assertFalse($result);
74  }
75 
77  {
78  $settings = $this->getMockBuilder(ilSetting::class)
79  ->disableOriginalConstructor()
80  ->getMock();
81 
82  $settings->method('get')
83  ->with('active')
84  ->willReturn('1');
85 
86  $rpcSettings = $this->getMockBuilder(ilRPCServerSettings::class)
87  ->disableOriginalConstructor()
88  ->getMock();
89 
90  $rpcSettings
91  ->expects($this->once())
92  ->method('isEnabled')
93  ->willReturn(false);
94 
95  $validator = new ilCertificateActiveValidator($settings, $rpcSettings);
96 
97  $result = $validator->validate();
98 
99  $this->assertFalse($result);
100  }
101 }