Commit 3ba21f2f authored by Doris Tam's avatar Doris Tam 🌷 Committed by Robert Lyon
Browse files

Bug 1919559: Add general page comments to behat testing data

Change-Id: I5c096c3f7e1bc45aa061e5678e590914639fa605
parent c4061192
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -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
+11 −0
Original line number Diff line number Diff line
@@ -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')
        )
      );

+25 −18
Original line number Diff line number Diff line
@@ -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:
@@ -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