Skip to content

Commit

Permalink
forum subscription tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffcaseyyet committed Oct 24, 2024
1 parent 5009e2a commit b6954fe
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* David Pesce <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class existing_module_test extends \logstore_xapi\xapi_test_case {
class discussion_created_test extends \logstore_xapi\xapi_test_case {

/**
* Retrieve the directory of the unit test.
Expand Down
20 changes: 20 additions & 0 deletions tests/mod_forum/subscription_created/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"modules": [
{
"id": 1,
"name": "forum"
}
],
"forum": [
{
"id": 1,
"name": "test_forum_name"
}
],
"forum_discussions": [
{
"id": 1,
"name": "test_forum_discussion_name"
}
]
}
10 changes: 10 additions & 0 deletions tests/mod_forum/subscription_created/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": 1,
"userid": 1,
"courseid": 1,
"timecreated": 1433946701,
"objecttable": "forum",
"objectid": 1,
"contextinstanceid": 1,
"eventname": "\\mod_forum\\event\\subscription_created"
}
71 changes: 71 additions & 0 deletions tests/mod_forum/subscription_created/statements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[
{
"actor": {
"name": "test_fullname",
"account": {
"homePage": "http://www.example.org",
"name": "1"
}
},
"verb": {
"id": "https://xapi.edlm/profiles/edlm-lms/concepts/verbs/subscribed",
"display": {
"en": "Subscribed"
}
},
"object": {
"id": "http://www.example.org/mod/forum/view.php?id=1",
"definition": {
"type": "https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/forum",
"name": {
"en": "test_forum_name"
}
}
},
"context": {
"language": "en",
"extensions": {
"http://lrs.learninglocker.net/define/extensions/info": {
"http://moodle.org": "1.0.0",
"https://github.com/xAPI-vle/moodle-logstore_xapi": "0.0.0-development",
"event_name": "\\mod_forum\\event\\subscription_created",
"event_function": "\\src\\transformer\\events\\mod_forum\\subscription_created"
}
},
"contextActivities": {
"parent": [
{
"id": "http://www.example.org/course/section.php?id=1",
"objectType": "Activity",
"definition": {
"name": {
"en": "test_name Section 0"
},
"type": "http://id.tincanapi.com/activitytype/section"
}
},
{
"id": "http://www.example.org/course/view.php?id=1",
"definition": {
"type": "https://w3id.org/xapi/cmi5/activitytype/course",
"name": {
"en": "test_name"
}
}
}
],
"category": [
{
"id": "http://www.example.org",
"definition": {
"type": "http://id.tincanapi.com/activitytype/lms",
"name": {
"en": "test_name"
}
}
}
]
}
}
}
]
72 changes: 72 additions & 0 deletions tests/mod_forum/subscription_created/subscription_created_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace logstore_xapi\mod_forum\discussion_created;

defined('MOODLE_INTERNAL') || die();

global $CFG;

require_once($CFG->dirroot . '/admin/tool/log/store/xapi/tests/xapi_test_case.php');

/**
* Unit test for mod_forum discussion created event.
*
* @package logstore_xapi
* @copyright Jerret Fowler <[email protected]>
* Ryan Smith <https://www.linkedin.com/in/ryan-smith-uk/>
* David Pesce <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class subscription_created_test extends \logstore_xapi\xapi_test_case {

/**
* Retrieve the directory of the unit test.
*
* @return string
*/
protected function get_test_dir() {
return __DIR__;
}

/**
* Retrieve the plugin type being tested.
*
* @return string
*/
protected function get_plugin_type() {
return "mod";
}

/**
* Retrieve the plugin name being tested.
*
* @return string
*/
protected function get_plugin_name() {
return "forum";
}

/**
* Appease auto-detecting of test cases. xapi_test_case has default test cases.
*
* @covers ::discussion_created
* @return void
*/
public function test_init() {

}
}
20 changes: 20 additions & 0 deletions tests/mod_forum/subscription_deleted/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"modules": [
{
"id": 1,
"name": "forum"
}
],
"forum": [
{
"id": 1,
"name": "test_forum_name"
}
],
"forum_discussions": [
{
"id": 1,
"name": "test_forum_discussion_name"
}
]
}
10 changes: 10 additions & 0 deletions tests/mod_forum/subscription_deleted/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": 1,
"userid": 1,
"courseid": 1,
"timecreated": 1433946701,
"objecttable": "forum",
"objectid": 1,
"contextinstanceid": 1,
"eventname": "\\mod_forum\\event\\subscription_deleted"
}
71 changes: 71 additions & 0 deletions tests/mod_forum/subscription_deleted/statements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[
{
"actor": {
"name": "test_fullname",
"account": {
"homePage": "http://www.example.org",
"name": "1"
}
},
"verb": {
"id": "https://xapi.edlm/profiles/edlm-lms/concepts/verbs/unsubscribed",
"display": {
"en": "Unsubscribed"
}
},
"object": {
"id": "http://www.example.org/mod/forum/view.php?id=1",
"definition": {
"type": "https://xapi.edlm/profiles/edlm-lms/concepts/activity-types/forum",
"name": {
"en": "test_forum_name"
}
}
},
"context": {
"language": "en",
"extensions": {
"http://lrs.learninglocker.net/define/extensions/info": {
"http://moodle.org": "1.0.0",
"https://github.com/xAPI-vle/moodle-logstore_xapi": "0.0.0-development",
"event_name": "\\mod_forum\\event\\subscription_deleted",
"event_function": "\\src\\transformer\\events\\mod_forum\\subscription_deleted"
}
},
"contextActivities": {
"parent": [
{
"id": "http://www.example.org/course/section.php?id=1",
"objectType": "Activity",
"definition": {
"name": {
"en": "test_name Section 0"
},
"type": "http://id.tincanapi.com/activitytype/section"
}
},
{
"id": "http://www.example.org/course/view.php?id=1",
"definition": {
"type": "https://w3id.org/xapi/cmi5/activitytype/course",
"name": {
"en": "test_name"
}
}
}
],
"category": [
{
"id": "http://www.example.org",
"definition": {
"type": "http://id.tincanapi.com/activitytype/lms",
"name": {
"en": "test_name"
}
}
}
]
}
}
}
]
72 changes: 72 additions & 0 deletions tests/mod_forum/subscription_deleted/subscription_deleted_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace logstore_xapi\mod_forum\discussion_created;

defined('MOODLE_INTERNAL') || die();

global $CFG;

require_once($CFG->dirroot . '/admin/tool/log/store/xapi/tests/xapi_test_case.php');

/**
* Unit test for mod_forum discussion created event.
*
* @package logstore_xapi
* @copyright Jerret Fowler <[email protected]>
* Ryan Smith <https://www.linkedin.com/in/ryan-smith-uk/>
* David Pesce <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class subscription_deleted_test extends \logstore_xapi\xapi_test_case {

/**
* Retrieve the directory of the unit test.
*
* @return string
*/
protected function get_test_dir() {
return __DIR__;
}

/**
* Retrieve the plugin type being tested.
*
* @return string
*/
protected function get_plugin_type() {
return "mod";
}

/**
* Retrieve the plugin name being tested.
*
* @return string
*/
protected function get_plugin_name() {
return "forum";
}

/**
* Appease auto-detecting of test cases. xapi_test_case has default test cases.
*
* @covers ::discussion_created
* @return void
*/
public function test_init() {

}
}

0 comments on commit b6954fe

Please sign in to comment.