Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
5d76fb65
Commit
5d76fb65
authored
Jan 24, 2019
by
Doris Tam
Browse files
Bug 1810990: blocktype data: recentforumpsts - create_forum() to create bulk forums
Change-Id: I9d9f345b0764c812d3e09e598557925b75d27eee
parent
b5e61f16
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/testing/classes/generator/TestingDataGenerator.php
View file @
5d76fb65
...
...
@@ -1464,7 +1464,7 @@ EOD;
* Currently it only supports adding title / description,
* | title | ownertype | ownername | description | pages |
* | collection one | user | UserA | desc of col |Page One,Page Two |
* @param
array
$record
* @param
unknown
$record
* @throws SystemException if creating failed
* @return int new collection id
*/
...
...
@@ -1640,6 +1640,59 @@ EOD;
$artefact
->
commit
();
}
/**
* A fixture to set up forums in bulk.
* Currently it doesn't support indenting and other additional settings
*
* And the following "forums" exist:
* | group | title | description | creator |
* | Group1 | unicorns! | magic mahara unicorns| UserB |
*
* @param unknown $record
* @throws SystemException
*/
public
function
create_forum
(
$record
)
{
$record
[
'title'
]
=
trim
(
$record
[
'title'
]);
$record
[
'description'
]
=
trim
(
$record
[
'description'
]);
$record
[
'creator'
]
=
trim
(
$record
[
'creator'
]);
$record
[
'group'
]
=
trim
(
$record
[
'group'
]);
$groupid
;
$creatorid
;
$isadmin
;
// check that the group exists
if
(
!
$groupid
=
get_field
(
'group'
,
'id'
,
'name'
,
$record
[
'group'
]
))
{
throw
new
SystemException
(
"Invalid group '"
.
$record
[
'group'
]
.
"'"
);
}
//check the creator exists as a user
if
(
!
$creatorid
=
get_field
(
'usr'
,
'id'
,
'username'
,
$record
[
'creator'
]))
{
throw
new
SystemException
(
"The user "
.
$record
[
'creator'
]
.
" doesn't exist"
);
}
//check that the creator is an admin of the group (for permission to create forum)
if
(
!
$isadmin
=
get_field
(
'group_member'
,
'member'
,
'group'
,
$groupid
,
'role'
,
"admin"
,
'member'
,
$creatorid
))
{
throw
new
SystemException
(
"The "
.
$record
[
'creator'
]
.
" does not have admin rights in group "
.
$record
[
'group'
]
.
"to create a forum"
);
}
$forum
=
new
InteractionForumInstance
(
0
,
(
object
)
array
(
'group'
=>
$groupid
,
'creator'
=>
$creatorid
,
'title'
=>
$record
[
'title'
],
'description'
=>
$record
[
'description'
]
));
$forum
->
commit
();
// configure other settings
PluginInteractionForum
::
instance_config_save
(
$forum
,
array
(
'createtopicusers'
=>
'members'
,
'autosubscribe'
=>
1
,
'justcreated'
=>
1
,
));
}
/**
* A fixture to set up messages in bulk.
* Currently it only supports setting friend request / accept internal notifications
...
...
htdocs/testing/frameworks/behat/classes/BehatDataGenerators.php
View file @
5d76fb65
...
...
@@ -228,6 +228,16 @@ class BehatDataGenerators extends BehatBase {
),
'required'
=>
array
(
'owner'
,
'ownertype'
,
'plan'
,
'title'
,
'completiondate'
)
),
'forums'
=>
array
(
'datagenerator'
=>
'forum'
,
'available'
=>
array
(
'title'
=>
'text'
,
'description'
=>
'text'
,
'group'
=>
'text'
,
'creator'
=>
'text'
),
'required'
=>
array
(
'title'
,
'description'
,
'group'
,
'creator'
)
)
);
/**
...
...
test/behat/features/user_content/test.feature
View file @
5d76fb65
...
...
@@ -12,17 +12,21 @@ Background:
|
UserB
|
Kupuh1pa!
|
UserB@example.org
|
Bob
|
Boi
|
mahara
|
internal
|
member
|
And the following "groups" exist
:
|
name
|
owner
|
description
|
grouptype
|
open
|
invitefriends
|
editroles
|
submittableto
|
allowarchives
|
members
|
staff
|
|
Group1
|
UserB
|
Group1
owned
by
UserB
|
standard
|
ON
|
OFF
|
all
|
ON
|
OFF
|
UserA
|
|
|
name
|
owner
|
description
|
grouptype
|
open
|
invitefriends
|
editroles
|
submittableto
|
allowarchives
|
members
|
staff
|
|
Group1
|
UserB
|
Group1
owned
by
UserB
|
standard
|
ON
|
OFF
|
all
|
ON
|
OFF
|
UserA
|
|
And the following "forums" exist
:
|
group
|
title
|
description
|
creator
|
|
Group1
|
unicorns!
|
magic
mahara
unicorns
|
UserB
|
And the following "pages" exist
:
|
title
|
description
|
ownertype
|
ownername
|
|
Page
UserA_00
|
Page
01
|
user
|
UserA
|
|
Page
UserB_00
|
Page
01
|
user
|
UserA
|
|
Page
Grp1
|
Page
01
|
group
|
Group1
|
|
Page
One
|
test
01
|
user
|
UserA
|
|
Page
Two
|
test
01
|
user
|
UserA
|
|
Page
Three
|
test
01
|
user
|
UserA
|
|
Page
UserA_00
|
Page
01
|
user
|
UserA
|
|
Page
UserB_00
|
Page
01
|
user
|
UserA
|
|
Page
Grp1
|
Page
01
|
group
|
Group1
|
|
Page
One
|
test
01
|
user
|
UserA
|
|
Page
Two
|
test
01
|
user
|
UserA
|
|
Page
Three
|
test
01
|
user
|
UserA
|
And the following "collections" exist
:
|
title
|
ownertype
|
ownername
|
description
|
pages
|
...
...
@@ -93,10 +97,7 @@ Background:
|
my
pdf
|
pdf
|
Page
Three
|
no
|
attachment=mahara_about.pdf
|
|
g
rcnt
posts
|
recentforumposts
|
Page
Three
|
no
|
groupname=Group1;
maxposts=-1
|
Scenario
:
Create Page UserA_00 with text blocks
Scenario
:
Login as admin to change upload settings
# To allow users to upload specific internal media types
Given
I log in as
"admin"
with password
"Kupuh1pa!"
And
I go to
"/admin/extensions/pluginconfig.php?plugintype=blocktype&pluginname=file/internalmedia"
...
...
@@ -116,7 +117,8 @@ Scenario: Create Page UserA_00 with text blocks
And
I press
"Save"
Then
I log out
Then
I log in as
"UserA"
with password
"Kupuh1pa!"
Scenario
:
Create Page with Blocks
Given
I log in as
"UserA"
with password
"Kupuh1pa!"
And
I go to portfolio page
"Page UserA_00"
And
I go to portfolio page
"Page Grp1"
And
I go to portfolio page
"Page UserB_00"
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment