Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 24... Línea 24...
24
 * @package    core
24
 * @package    core
25
 * @category   phpunit
25
 * @category   phpunit
26
 * @copyright  2013 Petr Skoda {@link http://skodak.org}
26
 * @copyright  2013 Petr Skoda {@link http://skodak.org}
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
28
 */
29
class environment_test extends \advanced_testcase {
29
final class environment_test extends \advanced_testcase {
Línea 30... Línea 30...
30
 
30
 
31
    /**
31
    /**
32
     * Test the environment check status.
32
     * Test the environment check status.
33
     */
33
     */
34
    public function test_environment_check_status() {
34
    public function test_environment_check_status(): void {
35
        global $CFG;
35
        global $CFG;
Línea 36... Línea 36...
36
        require_once($CFG->libdir.'/environmentlib.php');
36
        require_once($CFG->libdir.'/environmentlib.php');
Línea 45... Línea 45...
45
    /**
45
    /**
46
     * Data provider for Moodle environment check tests.
46
     * Data provider for Moodle environment check tests.
47
     *
47
     *
48
     * @return array
48
     * @return array
49
     */
49
     */
50
    public function environment_provider() {
50
    public static function environment_provider(): array {
51
        global $CFG;
51
        global $CFG;
52
        require_once($CFG->libdir.'/environmentlib.php');
52
        require_once($CFG->libdir.'/environmentlib.php');
Línea 53... Línea 53...
53
 
53
 
54
        $results = check_moodle_environment(normalize_version($CFG->release), ENV_SELECT_RELEASE);
54
        $results = check_moodle_environment(normalize_version($CFG->release), ENV_SELECT_RELEASE);
Línea 63... Línea 63...
63
     * Test the environment.
63
     * Test the environment.
64
     *
64
     *
65
     * @dataProvider environment_provider
65
     * @dataProvider environment_provider
66
     * @param environment_results $result
66
     * @param environment_results $result
67
     */
67
     */
68
    public function test_environment($result) {
68
    public function test_environment($result): void {
69
        $sslmessages = ['ssl/tls configuration not supported', 'invalid ssl/tls configuration'];
69
        $sslmessages = ['ssl/tls configuration not supported', 'invalid ssl/tls configuration'];
Línea 70... Línea 70...
70
 
70
 
71
        if ($result->part === 'php_setting'
71
        if ($result->part === 'php_setting'
72
                && $result->info === 'opcache.enable'
72
                && $result->info === 'opcache.enable'
73
                && $result->getLevel() === 'optional'
73
                && $result->getLevel() === 'optional'
74
                && $result->getStatus() === false) {
74
                && $result->getStatus() === false) {
75
            $this->markTestSkipped('OPCache extension is not necessary for unit testing.');
75
            $this->markTestSkipped('OPCache extension is not necessary for unit testing.');
Línea -... Línea 76...
-
 
76
        }
-
 
77
 
-
 
78
        if ($result->part === 'php_extension'
-
 
79
                && $result->getPluginName() !== ''
-
 
80
                && $result->getLevel() === 'optional'
-
 
81
                && $result->getStatus() === false) {
-
 
82
            $this->markTestSkipped('Optional plugin extension is not necessary for unit testing.');
76
        }
83
        }
77
 
84
 
78
        if ($result->part === 'custom_check'
85
        if ($result->part === 'custom_check'
79
                && $result->getLevel() === 'optional'
86
                && $result->getLevel() === 'optional'
80
                && $result->getStatus() === false) {
87
                && $result->getStatus() === false) {
Línea 95... Línea 102...
95
    }
102
    }
Línea 96... Línea 103...
96
 
103
 
97
    /**
104
    /**
98
     * Test the get_list_of_environment_versions() function.
105
     * Test the get_list_of_environment_versions() function.
99
     */
106
     */
100
    public function test_get_list_of_environment_versions() {
107
    public function test_get_list_of_environment_versions(): void {
101
        global $CFG;
108
        global $CFG;
102
        require_once($CFG->libdir.'/environmentlib.php');
109
        require_once($CFG->libdir.'/environmentlib.php');
103
        // Build a sample xmlised environment.xml.
110
        // Build a sample xmlised environment.xml.
104
        $xml = <<<END
111
        $xml = <<<END
Línea 141... Línea 148...
141
    }
148
    }
Línea 142... Línea 149...
142
 
149
 
143
    /**
150
    /**
144
     * Test the environment_verify_plugin() function.
151
     * Test the environment_verify_plugin() function.
145
     */
152
     */
146
    public function test_verify_plugin() {
153
    public function test_verify_plugin(): void {
147
        global $CFG;
154
        global $CFG;
148
        require_once($CFG->libdir.'/environmentlib.php');
155
        require_once($CFG->libdir.'/environmentlib.php');
149
        // Build sample xmlised environment file fragments.
156
        // Build sample xmlised environment file fragments.
150
        $plugin1xml = <<<END
157
        $plugin1xml = <<<END
Línea 171... Línea 178...
171
 
178
 
172
    /**
179
    /**
173
     * Test the restrict_php_version() function returns true if the current
180
     * Test the restrict_php_version() function returns true if the current
174
     * PHP version is greater than the restricted version
181
     * PHP version is greater than the restricted version
175
     */
182
     */
176
    public function test_restrict_php_version_greater_than_restricted_version() {
183
    public function test_restrict_php_version_greater_than_restricted_version(): void {
177
        global $CFG;
184
        global $CFG;
Línea 178... Línea 185...
178
        require_once($CFG->libdir.'/environmentlib.php');
185
        require_once($CFG->libdir.'/environmentlib.php');
179
 
186
 
Línea 194... Línea 201...
194
 
201
 
195
    /**
202
    /**
196
     * Test the restrict_php_version() function returns true if the current
203
     * Test the restrict_php_version() function returns true if the current
197
     * PHP version is equal to the restricted version
204
     * PHP version is equal to the restricted version
198
     */
205
     */
199
    public function test_restrict_php_version_equal_to_restricted_version() {
206
    public function test_restrict_php_version_equal_to_restricted_version(): void {
200
        global $CFG;
207
        global $CFG;
Línea 201... Línea 208...
201
        require_once($CFG->libdir.'/environmentlib.php');
208
        require_once($CFG->libdir.'/environmentlib.php');
202
 
209
 
Línea 213... Línea 220...
213
 
220
 
214
    /**
221
    /**
215
     * Test the restrict_php_version() function returns false if the current
222
     * Test the restrict_php_version() function returns false if the current
216
     * PHP version is less than the restricted version
223
     * PHP version is less than the restricted version
217
     */
224
     */
218
    public function test_restrict_php_version_less_than_restricted_version() {
225
    public function test_restrict_php_version_less_than_restricted_version(): void {
219
        global $CFG;
226
        global $CFG;
Línea 220... Línea 227...
220
        require_once($CFG->libdir.'/environmentlib.php');
227
        require_once($CFG->libdir.'/environmentlib.php');
221
 
228