Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| common_configuration_Mock | |
100.00% |
9 / 9 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| check | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| getExpectedStatus | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
| setExpectedStatus | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program 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 this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg |
| 19 | * (under the project TAO & TAO2); |
| 20 | * 2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung |
| 21 | * (under the project TAO-TRANSFER); |
| 22 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 23 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 24 | * |
| 25 | */ |
| 26 | |
| 27 | |
| 28 | /** |
| 29 | * A mock configuration component for which you can specify the type of report. |
| 30 | * for testing purpose. |
| 31 | * |
| 32 | * @access public |
| 33 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 34 | * @package generis |
| 35 | |
| 36 | */ |
| 37 | class common_configuration_Mock extends common_configuration_Component |
| 38 | { |
| 39 | // --- ASSOCIATIONS --- |
| 40 | |
| 41 | |
| 42 | // --- ATTRIBUTES --- |
| 43 | |
| 44 | /** |
| 45 | * The expected report status. |
| 46 | * |
| 47 | * @access private |
| 48 | * @var int |
| 49 | */ |
| 50 | private $expectedStatus = 0; |
| 51 | |
| 52 | // --- OPERATIONS --- |
| 53 | |
| 54 | /** |
| 55 | * Create a new Mock configuration component with an expected report status, |
| 56 | * a name. |
| 57 | * |
| 58 | * @access public |
| 59 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 60 | * @param int $expectedStatus The expected status of the report that will be provided by the check method. Must |
| 61 | * correspond to a constant of the Report class. |
| 62 | * @param string $name The name of the mock configuration component to make it identifiable among others. |
| 63 | * @return mixed |
| 64 | */ |
| 65 | public function __construct($expectedStatus, $name) |
| 66 | { |
| 67 | |
| 68 | $this->setExpectedStatus($expectedStatus); |
| 69 | $this->setName($name); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Fake configuration check that will provide a Report with the expected |
| 74 | * |
| 75 | * @access public |
| 76 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 77 | * @return mixed |
| 78 | */ |
| 79 | public function check() |
| 80 | { |
| 81 | |
| 82 | $message = 'Mock configuration report.'; |
| 83 | $report = new common_configuration_Report($this->getExpectedStatus(), $message, $this); |
| 84 | return $report; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Provide the expected status and contains a value defined by the status |
| 89 | * of the Report class. |
| 90 | * |
| 91 | * @access public |
| 92 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 93 | * @return int |
| 94 | */ |
| 95 | public function getExpectedStatus() |
| 96 | { |
| 97 | $returnValue = (int) 0; |
| 98 | |
| 99 | |
| 100 | $returnValue = $this->expectedStatus; |
| 101 | |
| 102 | |
| 103 | return (int) $returnValue; |
| 104 | } |
| 105 | |
| 106 | /** |
| 107 | * Set the expected status of the Mock configuration component. |
| 108 | * |
| 109 | * @access public |
| 110 | * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu> |
| 111 | * @param int expectedStatus A status corresponding to a constant value of the Report class. |
| 112 | * @return void |
| 113 | */ |
| 114 | public function setExpectedStatus($expectedStatus) |
| 115 | { |
| 116 | |
| 117 | $this->expectedStatus = $expectedStatus; |
| 118 | } |
| 119 | } |