ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilCertificateDownloadValidatorTest Class Reference
+ Inheritance diagram for ilCertificateDownloadValidatorTest:
+ Collaboration diagram for ilCertificateDownloadValidatorTest:

Public Member Functions

 testValidationSucceedsAndReturnsTrue ()
 
 testValidationReturnedFalseBecauseCertificateAreNotGloballyActivated ()
 
 testValidationReturnedFalseBecauseJavaServerIsNotActive ()
 

Detailed Description

Member Function Documentation

◆ testValidationReturnedFalseBecauseCertificateAreNotGloballyActivated()

ilCertificateDownloadValidatorTest::testValidationReturnedFalseBecauseCertificateAreNotGloballyActivated ( )

Definition at line 34 of file ilCertificateDownloadValidatorTest.php.

References $result.

35  {
36  $userCertificateRepository = $this->getMockBuilder('ilUserCertificateRepository')
37  ->disableOriginalConstructor()
38  ->getMock();
39 
40  $userCertificateRepository
41  ->expects($this->never())
42  ->method('fetchActiveCertificate');
43 
44  $accessValidator = new ilCertificateUserCertificateAccessValidator($userCertificateRepository);
45 
46  $activeValidator = $this->getMockBuilder('ilCertificateActiveValidator')
47  ->disableOriginalConstructor()
48  ->getMock();
49 
50  $activeValidator
51  ->method('validate')
52  ->willReturn(false);
53 
54  $validator = new ilCertificateDownloadValidator($accessValidator, $activeValidator);
55 
56  $result = $validator->isCertificateDownloadable(100, 100);
57 
58  $this->assertFalse($result);
59  }
$result
Validates if an active certificate is stored in the database and can be downloaded by the user...

◆ testValidationReturnedFalseBecauseJavaServerIsNotActive()

ilCertificateDownloadValidatorTest::testValidationReturnedFalseBecauseJavaServerIsNotActive ( )

Definition at line 61 of file ilCertificateDownloadValidatorTest.php.

References $result, and Sabre\Event\once().

62  {
63  $userCertificateRepository = $this->getMockBuilder('ilUserCertificateRepository')
64  ->disableOriginalConstructor()
65  ->getMock();
66 
67  $userCertificateRepository
68  ->expects($this->once())
69  ->method('fetchActiveCertificate')
70  ->willThrowException(new ilRpcClientException('Client not active'));
71 
72  $accessValidator = new ilCertificateUserCertificateAccessValidator($userCertificateRepository);
73 
74  $activeValidator = $this->getMockBuilder('ilCertificateActiveValidator')
75  ->disableOriginalConstructor()
76  ->getMock();
77 
78  $activeValidator
79  ->method('validate')
80  ->willReturn(true);
81 
82  $validator = new ilCertificateDownloadValidator($accessValidator, $activeValidator);
83 
84  $result = $validator->isCertificateDownloadable(100, 100);
85 
86  $this->assertFalse($result);
87  }
$result
Validates if an active certificate is stored in the database and can be downloaded by the user...
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
Class ilRpcClientException.
+ Here is the call graph for this function:

◆ testValidationSucceedsAndReturnsTrue()

ilCertificateDownloadValidatorTest::testValidationSucceedsAndReturnsTrue ( )

Definition at line 9 of file ilCertificateDownloadValidatorTest.php.

References $result.

10  {
11  $userCertificateRepository = $this->getMockBuilder('ilUserCertificateRepository')
12  ->disableOriginalConstructor()
13  ->getMock();
14 
15 
16  $userCertificateRepository->method('fetchActiveCertificate');
17 
18  $accessValidator = new ilCertificateUserCertificateAccessValidator($userCertificateRepository);
19 
20  $activeValidator = $this->getMockBuilder('ilCertificateActiveValidator')
21  ->disableOriginalConstructor()
22  ->getMock();
23 
24  $activeValidator->method('validate')
25  ->willReturn(true);
26 
27  $validator = new ilCertificateDownloadValidator($accessValidator, $activeValidator);
28 
29  $result = $validator->isCertificateDownloadable(100, 100);
30 
31  $this->assertTrue($result);
32  }
$result
Validates if an active certificate is stored in the database and can be downloaded by the user...

The documentation for this class was generated from the following file: