예제 #1
0
 /**
  * Returns testable subclass of the client.
  *
  * @return \core\update\testable_api
  */
 protected function get_update_api_client()
 {
     return \core\update\testable_api::client();
 }
예제 #2
0
 /**
  * Validating the pluginfo.php response data.
  */
 public function test_validate_pluginfo_format()
 {
     $client = \core\update\testable_api::client();
     $json = '{"id":127,"name":"Course contents","component":"block_course_contents","source":"https:\\/\\/github.com\\/mudrd8mz\\/moodle-block_course_contents","doc":"http:\\/\\/docs.moodle.org\\/20\\/en\\/Course_contents_block","bugs":"https:\\/\\/github.com\\/mudrd8mz\\/moodle-block_course_contents\\/issues","discussion":null,"version":{"id":8100,"version":"2015030300","release":"3.0","maturity":200,"downloadurl":"https:\\/\\/moodle.org\\/plugins\\/download.php\\/8100\\/block_course_contents_moodle29_2015030300.zip","downloadmd5":"8d8ae64822f38d278420776f8b42eaa5","vcssystem":"git","vcssystemother":null,"vcsrepositoryurl":"https:\\/\\/github.com\\/mudrd8mz\\/moodle-block_course_contents","vcsbranch":"master","vcstag":"v3.0","supportedmoodles":[{"version":2014041100,"release":"2.7"},{"version":2014101000,"release":"2.8"},{"version":2015041700,"release":"2.9"}]}}';
     $data = json_decode($json);
     $this->assertInstanceOf('\\core\\update\\remote_info', $client->validate_pluginfo_format($data));
     $this->assertEquals(json_encode($data), json_encode($client->validate_pluginfo_format($data)));
     // All properties must be present.
     unset($data->version);
     $this->assertFalse($client->validate_pluginfo_format($data));
     $data->version = false;
     $this->assertEquals(json_encode($data), json_encode($client->validate_pluginfo_format($data)));
     // Some properties may be empty.
     $data = json_decode($json);
     $data->version->release = null;
     $this->assertEquals(json_encode($data), json_encode($client->validate_pluginfo_format($data)));
     // Some properties must not be empty.
     $data = json_decode($json);
     $data->version->downloadurl = '';
     $this->assertFalse($client->validate_pluginfo_format($data));
     // Download URL may be http:// or https:// only.
     $data = json_decode($json);
     $data->version->downloadurl = 'ftp://archive.moodle.org/block_course_contents/2014041100.zip';
     $this->assertFalse($client->validate_pluginfo_format($data));
 }