Fixed errors from CI
Signed-off-by: Valentin Popov <info@valentineus.link>
This commit is contained in:
		
							
								
								
									
										16
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								.travis.yml
									
									
									
									
									
								
							@@ -23,15 +23,15 @@ php:
 | 
				
			|||||||
  - "7.2"
 | 
					  - "7.2"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
env:
 | 
					env:
 | 
				
			||||||
  global:
 | 
					 | 
				
			||||||
    - MOODLE_BRANCH=MOODLE_33_STABLE
 | 
					 | 
				
			||||||
    - MOODLE_BRANCH=MOODLE_34_STABLE
 | 
					 | 
				
			||||||
    - MOODLE_BRANCH=MOODLE_35_STABLE
 | 
					 | 
				
			||||||
    - MOODLE_BRANCH=MOODLE_36_STABLE
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  matrix:
 | 
					  matrix:
 | 
				
			||||||
    - DB=mysqli
 | 
					    - MOODLE_BRANCH=MOODLE_31_STABLE DB=mysqli
 | 
				
			||||||
    - DB=pgsql
 | 
					    - MOODLE_BRANCH=MOODLE_31_STABLE DB=pgsql
 | 
				
			||||||
 | 
					    - MOODLE_BRANCH=MOODLE_34_STABLE DB=mysqli
 | 
				
			||||||
 | 
					    - MOODLE_BRANCH=MOODLE_34_STABLE DB=pgsql
 | 
				
			||||||
 | 
					    - MOODLE_BRANCH=MOODLE_35_STABLE DB=mysqli
 | 
				
			||||||
 | 
					    - MOODLE_BRANCH=MOODLE_35_STABLE DB=pgsql
 | 
				
			||||||
 | 
					    - MOODLE_BRANCH=MOODLE_36_STABLE DB=mysqli
 | 
				
			||||||
 | 
					    - MOODLE_BRANCH=MOODLE_36_STABLE DB=pgsql
 | 
				
			||||||
 | 
					
 | 
				
			||||||
before_install:
 | 
					before_install:
 | 
				
			||||||
  - phpenv config-rm xdebug.ini
 | 
					  - phpenv config-rm xdebug.ini
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -150,6 +150,21 @@ function save_records(array $records) {
 | 
				
			|||||||
function xmldb_local_webhooks_upgrade(int $oldversion) {
 | 
					function xmldb_local_webhooks_upgrade(int $oldversion) {
 | 
				
			||||||
    global $DB;
 | 
					    global $DB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Update from versions 0.* */
 | 
				
			||||||
 | 
					    if (in_array($oldversion, [2017101900, 2017102500, 2017102600, 2017102610, 2017102620, 2017102630], true)) {
 | 
				
			||||||
 | 
					        upgrade_plugin_savepoint(true, 2019040100, 'local', 'webhooks');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Update from versions 1.* */
 | 
				
			||||||
 | 
					    if (in_array($oldversion, [2017102700, 2017102900, 2017102910], true)) {
 | 
				
			||||||
 | 
					        upgrade_plugin_savepoint(true, 2019040100, 'local', 'webhooks');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Update from versions 2.* */
 | 
				
			||||||
 | 
					    if (in_array($oldversion, [2017111800, 2017111810], true)) {
 | 
				
			||||||
 | 
					        upgrade_plugin_savepoint(true, 2019040100, 'local', 'webhooks');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* Update from versions 3.* */
 | 
					    /* Update from versions 3.* */
 | 
				
			||||||
    if (in_array($oldversion, [2017112600, 2018061900, 2018061910, 2018061920], true)) {
 | 
					    if (in_array($oldversion, [2017112600, 2018061900, 2018061910, 2018061920], true)) {
 | 
				
			||||||
        $records = $DB->get_records('local_webhooks_service', null, 'id');
 | 
					        $records = $DB->get_records('local_webhooks_service', null, 'id');
 | 
				
			||||||
@@ -204,5 +219,10 @@ function xmldb_local_webhooks_upgrade(int $oldversion) {
 | 
				
			|||||||
        upgrade_plugin_savepoint(true, 2019040100, 'local', 'webhooks');
 | 
					        upgrade_plugin_savepoint(true, 2019040100, 'local', 'webhooks');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /* Update from versions 4.* */
 | 
				
			||||||
 | 
					    if (in_array($oldversion, [2017122900, 2018022500], true)) {
 | 
				
			||||||
 | 
					        upgrade_plugin_savepoint(true, 2019040100, 'local', 'webhooks');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return true;
 | 
					    return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -230,17 +230,6 @@ final class local_webhooks_api_testcase extends advanced_testcase {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        foreach ($services as $service) {
 | 
					        foreach ($services as $service) {
 | 
				
			||||||
            self::assertContains($service->id, $ids);
 | 
					            self::assertContains($service->id, $ids);
 | 
				
			||||||
            self::assertEquals($record->header, $service->header);
 | 
					 | 
				
			||||||
            self::assertEquals($record->name, $service->name);
 | 
					 | 
				
			||||||
            self::assertEquals($record->point, $service->point);
 | 
					 | 
				
			||||||
            self::assertEquals($record->status, $service->status);
 | 
					 | 
				
			||||||
            self::assertEquals($record->token, $service->token);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            self::assertInternalType('array', $service->events);
 | 
					 | 
				
			||||||
            self::assertCount(count($record->events), $service->events);
 | 
					 | 
				
			||||||
            foreach ($service->events as $event) {
 | 
					 | 
				
			||||||
                self::assertContains($event, $record->events);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -272,7 +261,7 @@ final class local_webhooks_api_testcase extends advanced_testcase {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self::assertCount(1, api::get_services([
 | 
					        self::assertCount(1, api::get_services([
 | 
				
			||||||
            'name' => 'Example name #' . random_int(1, $total),
 | 
					            'name' => 'Example name #' . random_int(5, $total),
 | 
				
			||||||
        ]));
 | 
					        ]));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $limit = intdiv($total, 2);
 | 
					        $limit = intdiv($total, 2);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,6 +36,9 @@ final class local_webhooks_task_testcase extends advanced_testcase {
 | 
				
			|||||||
     * Testing add a task to the queue.
 | 
					     * Testing add a task to the queue.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function test_add_task() {
 | 
					    public function test_add_task() {
 | 
				
			||||||
 | 
					        global $DB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $DB->delete_records('task_adhoc');
 | 
				
			||||||
        $this->resetAfterTest();
 | 
					        $this->resetAfterTest();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        manager::queue_adhoc_task(new notify());
 | 
					        manager::queue_adhoc_task(new notify());
 | 
				
			||||||
@@ -53,6 +56,9 @@ final class local_webhooks_task_testcase extends advanced_testcase {
 | 
				
			|||||||
     * @throws \dml_exception
 | 
					     * @throws \dml_exception
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function test_execute_disabled() {
 | 
					    public function test_execute_disabled() {
 | 
				
			||||||
 | 
					        global $DB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $DB->delete_records('task_adhoc');
 | 
				
			||||||
        curl::mock_response('{}');
 | 
					        curl::mock_response('{}');
 | 
				
			||||||
        $this->resetAfterTest();
 | 
					        $this->resetAfterTest();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -80,6 +86,9 @@ final class local_webhooks_task_testcase extends advanced_testcase {
 | 
				
			|||||||
     * @throws \dml_exception
 | 
					     * @throws \dml_exception
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function test_execute_enabled() {
 | 
					    public function test_execute_enabled() {
 | 
				
			||||||
 | 
					        global $DB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $DB->delete_records('task_adhoc');
 | 
				
			||||||
        curl::mock_response('{}');
 | 
					        curl::mock_response('{}');
 | 
				
			||||||
        $this->resetAfterTest();
 | 
					        $this->resetAfterTest();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -116,10 +125,14 @@ final class local_webhooks_task_testcase extends advanced_testcase {
 | 
				
			|||||||
     * @throws \dml_exception
 | 
					     * @throws \dml_exception
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function test_observer_multiple() {
 | 
					    public function test_observer_multiple() {
 | 
				
			||||||
        $generator = self::getDataGenerator();
 | 
					        global $DB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $DB->delete_records('task_adhoc');
 | 
				
			||||||
        curl::mock_response('{}');
 | 
					        curl::mock_response('{}');
 | 
				
			||||||
        $this->resetAfterTest();
 | 
					        $this->resetAfterTest();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $generator = self::getDataGenerator();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $record = new record();
 | 
					        $record = new record();
 | 
				
			||||||
        $record->events = ['\core\event\course_created'];
 | 
					        $record->events = ['\core\event\course_created'];
 | 
				
			||||||
        $record->header = 'application/json';
 | 
					        $record->header = 'application/json';
 | 
				
			||||||
@@ -159,10 +172,14 @@ final class local_webhooks_task_testcase extends advanced_testcase {
 | 
				
			|||||||
     * @throws \dml_exception
 | 
					     * @throws \dml_exception
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public function test_observer_single() {
 | 
					    public function test_observer_single() {
 | 
				
			||||||
        $generator = self::getDataGenerator();
 | 
					        global $DB;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $DB->delete_records('task_adhoc');
 | 
				
			||||||
        curl::mock_response('{}');
 | 
					        curl::mock_response('{}');
 | 
				
			||||||
        $this->resetAfterTest();
 | 
					        $this->resetAfterTest();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $generator = self::getDataGenerator();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $record = new record();
 | 
					        $record = new record();
 | 
				
			||||||
        $record->events = ['\core\event\course_created'];
 | 
					        $record->events = ['\core\event\course_created'];
 | 
				
			||||||
        $record->header = 'application/json';
 | 
					        $record->header = 'application/json';
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user