Línea 30... |
Línea 30... |
30 |
* @copyright 2013, 2015 David Mudrak <david@moodle.com>
|
30 |
* @copyright 2013, 2015 David Mudrak <david@moodle.com>
|
31 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
31 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
32 |
*/
|
32 |
*/
|
33 |
class update_validator_test extends \advanced_testcase {
|
33 |
class update_validator_test extends \advanced_testcase {
|
Línea 34... |
Línea 34... |
34 |
|
34 |
|
35 |
public function test_validate_files_layout() {
|
35 |
public function test_validate_files_layout(): void {
|
Línea 36... |
Línea 36... |
36 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
36 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
37 |
|
37 |
|
38 |
// Non-existing directory.
|
38 |
// Non-existing directory.
|
Línea 105... |
Línea 105... |
105 |
$this->assertFalse($validator->execute());
|
105 |
$this->assertFalse($validator->execute());
|
106 |
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'rootdirinvalid',
|
106 |
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'rootdirinvalid',
|
107 |
'moodle-repository_mahara-master'));
|
107 |
'moodle-repository_mahara-master'));
|
108 |
}
|
108 |
}
|
Línea 109... |
Línea 109... |
109 |
|
109 |
|
110 |
public function test_validate_version_php() {
|
110 |
public function test_validate_version_php(): void {
|
Línea 111... |
Línea 111... |
111 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
111 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
112 |
|
112 |
|
113 |
$validator = testable_core_update_validator::instance($fixtures.'/noversiontheme', array(
|
113 |
$validator = testable_core_update_validator::instance($fixtures.'/noversiontheme', array(
|
Línea 186... |
Línea 186... |
186 |
$this->assertEquals('MATURITY_ALPHA', $versionphpinfo['maturity']); // Note we get the constant name here.
|
186 |
$this->assertEquals('MATURITY_ALPHA', $versionphpinfo['maturity']); // Note we get the constant name here.
|
187 |
$this->assertEquals(MATURITY_ALPHA, constant($versionphpinfo['maturity'])); // This is how to get the real value.
|
187 |
$this->assertEquals(MATURITY_ALPHA, constant($versionphpinfo['maturity'])); // This is how to get the real value.
|
188 |
$this->assertTrue($this->has_message($validator->get_messages(), $validator::WARNING, 'maturity', 'MATURITY_ALPHA'));
|
188 |
$this->assertTrue($this->has_message($validator->get_messages(), $validator::WARNING, 'maturity', 'MATURITY_ALPHA'));
|
189 |
}
|
189 |
}
|
Línea 190... |
Línea 190... |
190 |
|
190 |
|
191 |
public function test_validate_language_pack() {
|
191 |
public function test_validate_language_pack(): void {
|
Línea 192... |
Línea 192... |
192 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
192 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
193 |
|
193 |
|
194 |
$validator = testable_core_update_validator::instance($fixtures.'/nolang', array(
|
194 |
$validator = testable_core_update_validator::instance($fixtures.'/nolang', array(
|
Línea 260... |
Línea 260... |
260 |
$this->assertTrue($validator->execute());
|
260 |
$this->assertTrue($validator->execute());
|
261 |
$this->assertTrue($this->has_message($validator->get_messages(), $validator::DEBUG, 'foundlangfile', 'local_foobar'));
|
261 |
$this->assertTrue($this->has_message($validator->get_messages(), $validator::DEBUG, 'foundlangfile', 'local_foobar'));
|
262 |
$this->assertEquals('local_foobar', $validator->get_language_file_name());
|
262 |
$this->assertEquals('local_foobar', $validator->get_language_file_name());
|
263 |
}
|
263 |
}
|
Línea 264... |
Línea 264... |
264 |
|
264 |
|
265 |
public function test_validate_target_location() {
|
265 |
public function test_validate_target_location(): void {
|
Línea 266... |
Línea 266... |
266 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
266 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
267 |
|
267 |
|
268 |
$validator = testable_core_update_validator::instance($fixtures.'/installed', array(
|
268 |
$validator = testable_core_update_validator::instance($fixtures.'/installed', array(
|
Línea 306... |
Línea 306... |
306 |
$this->assertTrue($validator->execute());
|
306 |
$this->assertTrue($validator->execute());
|
307 |
$this->assertTrue($this->has_message($validator->get_messages(), $validator::INFO, 'pathwritable',
|
307 |
$this->assertTrue($this->has_message($validator->get_messages(), $validator::INFO, 'pathwritable',
|
308 |
$validator->get_plugintype_location('local')));
|
308 |
$validator->get_plugintype_location('local')));
|
309 |
}
|
309 |
}
|
Línea 310... |
Línea 310... |
310 |
|
310 |
|
311 |
public function test_parse_version_php() {
|
311 |
public function test_parse_version_php(): void {
|
Línea 312... |
Línea 312... |
312 |
$fixtures = __DIR__.'/fixtures/update_validator/versionphp';
|
312 |
$fixtures = __DIR__.'/fixtures/update_validator/versionphp';
|
313 |
|
313 |
|
Línea 324... |
Línea 324... |
324 |
$this->assertEquals('MATURITY_ALPHA', $info['plugin->maturity']); // Constant wins regardless the order (non-PHP behaviour).
|
324 |
$this->assertEquals('MATURITY_ALPHA', $info['plugin->maturity']); // Constant wins regardless the order (non-PHP behaviour).
|
325 |
$this->assertEquals('v2.3', $info['module->release']); // String wins over numeric (non-PHP behaviour).
|
325 |
$this->assertEquals('v2.3', $info['module->release']); // String wins over numeric (non-PHP behaviour).
|
326 |
$this->assertEquals('v2.4', $info['plugin->release']); // String wins over numeric (non-PHP behaviour).
|
326 |
$this->assertEquals('v2.4', $info['plugin->release']); // String wins over numeric (non-PHP behaviour).
|
327 |
}
|
327 |
}
|
Línea 328... |
Línea 328... |
328 |
|
328 |
|
329 |
public function test_messages_output() {
|
329 |
public function test_messages_output(): void {
|
330 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
330 |
$fixtures = __DIR__.'/fixtures/update_validator';
|
Línea 331... |
Línea 331... |
331 |
$validator = testable_core_update_validator::instance($fixtures, array());
|
331 |
$validator = testable_core_update_validator::instance($fixtures, array());
|
332 |
|
332 |
|