Loading htdocs/testing/classes/generator/TestingDataGenerator.php +24 −0 Original line number Diff line number Diff line Loading @@ -2467,6 +2467,30 @@ EOD; $activity->notify_users(); } public function create_page_comment($record) { $data = new stdClass(); $onview = $this->get_view_id($record['page']); if (!$viewrecord = get_record('view', 'id', $onview)) { throw new ViewNotFoundException(get_string('viewnotfound', 'error', $onview)); } $data->onview = $onview; require_once('view.php'); $view = new View($onview); $ownerid = $view->get('owner'); $data->owner = $ownerid; $data->author = $this->get_user_id($record['user']); $data->private = !empty($record['private']) ? 1 : 0; $data->title = 'Comment'; $comment = new ArtefactTypeComment(0, $data); $comment->commit(); $newdescription = EmbeddedImage::prepare_embedded_images($record['comment'], 'comment', $comment->get('id'), null , $ownerid); $updatedcomment = new stdClass(); $updatedcomment->id = $comment->get('id'); $updatedcomment->description = $newdescription; update_record('artefact', $updatedcomment, 'id'); } /** * A fixture to set up page & collection permissions. Currently it only supports setting a blanket permission of * "public", "loggedin", "friends", "private", "user + role", and allowcomments & approvecomments Loading htdocs/testing/frameworks/behat/classes/BehatDataGenerators.php +11 −0 Original line number Diff line number Diff line Loading @@ -376,6 +376,17 @@ class BehatDataGenerators extends BehatBase { 'attachment' => 'text' ), 'required' => array('user','startdate','title') ), 'pagecomments' => array( 'datagenerator' => 'page_comment', 'available' => array( 'user' => 'text', 'comment' => 'text', 'attachment' => 'text', 'private' => 'bool', 'page' => 'text' ), 'required' => array('user', 'comment', 'page') ) ); Loading test/behat/features/user_content/test.feature +25 −18 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ Background: Given the following "users" exist: # Available fields: username*, password*, email*, firstname*, lastname*, institution, role, authname, remoteusername, studentid, preferredname, town, country, occupation | username | password | email | firstname | lastname | institution | authname | role | | UserA | Kupuh1pa!| UserA@example.org | Painterio | Mahara | mahara | internal | member | | UserA | Kupuh1pa!| UserA@example.org | Painterio | Mahara | mahara | internal | admin | | UserB | Kupuh1pa!| UserB@example.org | Mechania | Mahara | mahara | internal | member | And the following "groups" exist: Loading Loading @@ -125,10 +125,17 @@ Background: | Page One B | UserB Page 1 | user | UserB | | Page One Grp | Group Page 1 | group | Group1 | And the following "pagecomments" exist: # Available fields: user*, comment*, page*, attachment, private | user | page | comment | private | | UserB | Page Two A | Comment by User B on page | false | | UserB | Page Three A | Hi, I am a comment by User B | false | | UserA | Page Three A | Hi, I am a comment by the owner | false | And the following "collections" exist: # Available fields: title*, description, ownertype*, ownername*, pages | title | ownertype | ownername | lock | description | pages | | collection one | user | UserA | false |desc of col | Page One A, Page Two A | | title | ownertype | ownername | description | pages | | collection one | user | UserA | desc of col | Page One A, Page Two A, Page Three A | And the following "journals" exist: # Available fields: owner*, ownertype*, title*, description, tags Loading Loading
htdocs/testing/classes/generator/TestingDataGenerator.php +24 −0 Original line number Diff line number Diff line Loading @@ -2467,6 +2467,30 @@ EOD; $activity->notify_users(); } public function create_page_comment($record) { $data = new stdClass(); $onview = $this->get_view_id($record['page']); if (!$viewrecord = get_record('view', 'id', $onview)) { throw new ViewNotFoundException(get_string('viewnotfound', 'error', $onview)); } $data->onview = $onview; require_once('view.php'); $view = new View($onview); $ownerid = $view->get('owner'); $data->owner = $ownerid; $data->author = $this->get_user_id($record['user']); $data->private = !empty($record['private']) ? 1 : 0; $data->title = 'Comment'; $comment = new ArtefactTypeComment(0, $data); $comment->commit(); $newdescription = EmbeddedImage::prepare_embedded_images($record['comment'], 'comment', $comment->get('id'), null , $ownerid); $updatedcomment = new stdClass(); $updatedcomment->id = $comment->get('id'); $updatedcomment->description = $newdescription; update_record('artefact', $updatedcomment, 'id'); } /** * A fixture to set up page & collection permissions. Currently it only supports setting a blanket permission of * "public", "loggedin", "friends", "private", "user + role", and allowcomments & approvecomments Loading
htdocs/testing/frameworks/behat/classes/BehatDataGenerators.php +11 −0 Original line number Diff line number Diff line Loading @@ -376,6 +376,17 @@ class BehatDataGenerators extends BehatBase { 'attachment' => 'text' ), 'required' => array('user','startdate','title') ), 'pagecomments' => array( 'datagenerator' => 'page_comment', 'available' => array( 'user' => 'text', 'comment' => 'text', 'attachment' => 'text', 'private' => 'bool', 'page' => 'text' ), 'required' => array('user', 'comment', 'page') ) ); Loading
test/behat/features/user_content/test.feature +25 −18 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ Background: Given the following "users" exist: # Available fields: username*, password*, email*, firstname*, lastname*, institution, role, authname, remoteusername, studentid, preferredname, town, country, occupation | username | password | email | firstname | lastname | institution | authname | role | | UserA | Kupuh1pa!| UserA@example.org | Painterio | Mahara | mahara | internal | member | | UserA | Kupuh1pa!| UserA@example.org | Painterio | Mahara | mahara | internal | admin | | UserB | Kupuh1pa!| UserB@example.org | Mechania | Mahara | mahara | internal | member | And the following "groups" exist: Loading Loading @@ -125,10 +125,17 @@ Background: | Page One B | UserB Page 1 | user | UserB | | Page One Grp | Group Page 1 | group | Group1 | And the following "pagecomments" exist: # Available fields: user*, comment*, page*, attachment, private | user | page | comment | private | | UserB | Page Two A | Comment by User B on page | false | | UserB | Page Three A | Hi, I am a comment by User B | false | | UserA | Page Three A | Hi, I am a comment by the owner | false | And the following "collections" exist: # Available fields: title*, description, ownertype*, ownername*, pages | title | ownertype | ownername | lock | description | pages | | collection one | user | UserA | false |desc of col | Page One A, Page Two A | | title | ownertype | ownername | description | pages | | collection one | user | UserA | desc of col | Page One A, Page Two A, Page Three A | And the following "journals" exist: # Available fields: owner*, ownertype*, title*, description, tags Loading