Passed
Push — master ( 2bb8d1...bedc70 )
by Stefan
03:11
created

MockProfileSilverbullet::revokeCertificate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A MockProfileSilverbullet::isGeneratedCertificate() 0 2 2
1
<?php
2
/* 
3
 *******************************************************************************
4
 * Copyright 2011-2017 DANTE Ltd. and GÉANT on behalf of the GN3, GN3+, GN4-1 
5
 * and GN4-2 consortia
6
 *
7
 * License: see the web/copyright.php file in the file structure
8
 *******************************************************************************
9
 */
10
11
/**
12
 * 
13
 * @author Zilvinas Vaira
14
 *
15
 */
16
class MockProfileSilverbullet extends \core\ProfileSilverbullet{
17
    
18
    /**
19
     * 
20
     * @var int
21
     */
22
    private $instId;
23
    
24
    /**
25
     * 
26
     * @var array
27
     */
28
    private $generatedCertificates = array();
29
    
30
    /**
31
     * 
32
     * @param \core\DBConnection $databaseHandle
33
     */
34
    public function __construct(\core\DBConnection $databaseHandle){
35
        $this->databaseHandle = $databaseHandle;
36
        if($this->databaseHandle->exec("INSERT INTO institution (country) VALUES('LT')")){
37
            $this->instId = $this->databaseHandle->lastID();
38
        }
39
        if($this->databaseHandle->exec("INSERT INTO profile (inst_id, realm) VALUES($this->instId, 'test.realm.tst')")){
40
            $this->identifier = $this->databaseHandle->lastID();
41
        }
42
        $this->attributes = array(array('name' => 'hiddenprofile:tou_accepted'));
43
    }
44
    
45
    /**
46
     * 
47
     */
48
    public function delete(){
49
        $this->databaseHandle->exec("DELETE FROM `institution` WHERE `inst_id`='" . $this->instId . "'");
50
        $this->databaseHandle->exec("DELETE FROM `profile` WHERE `profile_id`='" . $this->identifier . "'");
51
    }
52
    
53
    /**
54
     * 
55
     * {@inheritDoc}
56
     * @see \core\ProfileSilverbullet::generateCertificate()
57
     */
58
    public function generateCertificate($serial, $cn){
59
        $this->generatedCertificates[$serial] = $cn;
60
    }
61
        
62
    /**
63
     * 
64
     * @param string $serial
65
     * @param string $cn
66
     * @return boolean
67
     */
68
    public function isGeneratedCertificate($serial, $cn){
69
        return isset($this->generatedCertificates[$serial]) && $this->generatedCertificates[$serial]==$cn;
70
    }
71
}
72