1 |
efrain |
1 |
<?php
|
|
|
2 |
// This file is part of Moodle - http://moodle.org/
|
|
|
3 |
//
|
|
|
4 |
// Moodle is free software: you can redistribute it and/or modify
|
|
|
5 |
// it under the terms of the GNU General Public License as published by
|
|
|
6 |
// the Free Software Foundation, either version 3 of the License, or
|
|
|
7 |
// (at your option) any later version.
|
|
|
8 |
//
|
|
|
9 |
// Moodle is distributed in the hope that it will be useful,
|
|
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
// GNU General Public License for more details.
|
|
|
13 |
//
|
|
|
14 |
// You should have received a copy of the GNU General Public License
|
|
|
15 |
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
16 |
|
|
|
17 |
/**
|
|
|
18 |
* PHPUnit tool_brickfield tests
|
|
|
19 |
*
|
|
|
20 |
* @package tool_brickfield
|
|
|
21 |
* @copyright 2020 onward: Brickfield Education Labs, www.brickfield.ie
|
|
|
22 |
* @author Mike Churchward (mike@brickfieldlabs.ie)
|
|
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
24 |
*/
|
|
|
25 |
|
|
|
26 |
namespace tool_brickfield;
|
|
|
27 |
|
|
|
28 |
defined('MOODLE_INTERNAL') || die();
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* Mock brickfield connect.
|
|
|
32 |
*/
|
|
|
33 |
class mock_brickfieldconnect extends brickfieldconnect {
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
* Valid api key.
|
|
|
37 |
*/
|
|
|
38 |
const VALIDAPIKEY = '123456789012345678901234567890ab';
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Valid secret key.
|
|
|
42 |
*/
|
|
|
43 |
const VALIDSECRETKEY = 'ab123456789012345678901234567890';
|
|
|
44 |
|
|
|
45 |
/** @var string api key. */
|
|
|
46 |
protected $apikey = '';
|
|
|
47 |
|
|
|
48 |
/** @var string Secret key. */
|
|
|
49 |
protected $secretkey = '';
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Is registered.
|
|
|
53 |
* @return bool is registered
|
|
|
54 |
*/
|
|
|
55 |
public function is_registered(): bool {
|
|
|
56 |
return ($this->apikey == self::VALIDAPIKEY) && ($this->secretkey == self::VALIDSECRETKEY);
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
|
|
60 |
* Update Registration.
|
|
|
61 |
* @param string $apikey
|
|
|
62 |
* @param string $secretkey
|
|
|
63 |
* @return bool
|
|
|
64 |
*/
|
|
|
65 |
public function update_registration(string $apikey, string $secretkey): bool {
|
|
|
66 |
$this->apikey = $apikey;
|
|
|
67 |
$this->secretkey = $secretkey;
|
|
|
68 |
return $this->is_registered();
|
|
|
69 |
}
|
|
|
70 |
}
|