MDL-50874 block: basic tests for tag-related blocks

This commit is contained in:
Marina Glancy 2015-07-18 22:43:48 +08:00
parent e1d4e288ac
commit 9a7e398664
5 changed files with 189 additions and 4 deletions

View File

@ -0,0 +1,51 @@
@block @block_blog_tag @core_blog @core_tag
Feature: Adding blog tag block
In order to search blog post by tag
As a user
I need to be able to use block blog tag
Scenario: Adding block blog tag to the course
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | c1 |
And the following "tags" exist:
| name | tagtype |
| Neverusedtag | official |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | c1 | editingteacher |
| student1 | c1 | student |
When I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add the "Blog tags" block
And I navigate to "Course blogs" node in "Current course > c1 > Participants"
And I follow "Blog about this Course"
And I set the following fields to these values:
| Entry title | Blog post from teacher |
| Blog entry body | Teacher blog post content |
| Other tags (enter tags separated by commas) | Cats, dogs |
And I press "Save changes"
And I log out
And I log in as "student1"
And I follow "Course 1"
And I navigate to "Course blogs" node in "Current course > c1 > Participants"
And I follow "Blog about this Course"
And I set the following fields to these values:
| Entry title | Blog post from student |
| Blog entry body | Student blog post content |
| Other tags (enter tags separated by commas) | DOGS, mice |
And I press "Save changes"
And I follow "c1"
Then I should see "Cats" in the "Blog tags" "block"
And I should see "dogs" in the "Blog tags" "block"
And I should see "mice" in the "Blog tags" "block"
And I click on "Cats" "link" in the "Blog tags" "block"
And I should see "Blog post from teacher"
And I should see "Teacher blog post content"
And I log out

View File

@ -0,0 +1,64 @@
@block @block_tags @core_tag
Feature: Block tags displaying course tags
In order to tag courses
As a user
I need to be able to use the block tags
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
| student2 | Student | 2 | student2@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | c1 |
And the following "tags" exist:
| name | tagtype |
| Neverusedtag | official |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | c1 | editingteacher |
| student1 | c1 | student |
| student2 | c1 | student |
And I log in as "admin"
And I set the following administration settings values:
| Show course tags | 1 |
And I log out
Scenario: Add Tags block to tag courses in a course
When I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add the "Tags" block
And I log out
And I log in as "student1"
And I follow "Course 1"
And I should not see "Neverusedtag" in the "Tags" "block"
And I click on "more..." "link" in the "Tags" "block"
And I should not see "Neverusedtag"
And I follow "c1"
And I set the field "coursetag_new_tag" to "Dogs, Mice"
And I press "Add"
And I should see "Dogs" in the "Tags" "block"
And I should see "Mice" in the "Tags" "block"
And I log out
And I log in as "student2"
And I follow "Course 1"
And I should see "Dogs" in the "Tags" "block"
And I set the field "coursetag_new_tag" to "Cats, Dogs"
And I press "Add"
And I should see "Dogs" in the "Tags" "block"
And I should see "Cats" in the "Tags" "block"
And I click on "more..." "link" in the "Tags" "block"
And "Cats" "link" should appear before "Dogs" "link"
And "Dogs" "link" should appear before "Mice" "link"
And I follow "My tags"
And I should see "Dogs"
And I should see "Cats"
And I should not see "Mice"
And I follow "All tags"
And I follow "Popularity"
And "Mice" "link" should appear before "Dogs" "link"
And I should not see "Neverusedtag"
And I log out

View File

@ -0,0 +1,59 @@
@block @block_tags @core_tag
Feature: Block tags displaying tag cloud
In order to view system tags
As a user
I need to be able to use the block tags
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| teacher1 | Teacher | 1 | teacher1@example.com |
| student1 | Student | 1 | student1@example.com |
And the following "courses" exist:
| fullname | shortname |
| Course 1 | c1 |
And the following "tags" exist:
| name | tagtype |
| Neverusedtag | official |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | c1 | editingteacher |
| student1 | c1 | student |
And I log in as "teacher1"
And I follow "Preferences" in the user menu
And I follow "Edit profile"
And I expand all fieldsets
And I set the field "Enter tags separated by commas" to "Dogs, Cats"
And I press "Update profile"
And I log out
@javascript
Scenario: Add Tags block on a front page
When I log in as "admin"
And I am on site homepage
And I follow "Turn editing on"
And I add the "Tags" block
And I log out
And I am on site homepage
Then I should see "Dogs" in the "Tags" "block"
And I should see "Cats" in the "Tags" "block"
And I should not see "Neverusedtag" in the "Tags" "block"
And I click on "Dogs" "link" in the "Tags" "block"
And I should see "Log in to the site" in the ".breadcrumb" "css_element"
@javascript
Scenario: Add Tags block in a course
When I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add the "Tags" block
And I log out
And I log in as "student1"
And I follow "Course 1"
Then I should see "Dogs" in the "Tags" "block"
And I should see "Cats" in the "Tags" "block"
And I should not see "Neverusedtag" in the "Tags" "block"
And I click on "Dogs" "link" in the "Tags" "block"
And I should see "Users tagged with \"Dogs\": 1"
And I should see "Teacher 1"
And I log out

View File

@ -792,12 +792,19 @@ EOD;
$record['userid'] = $USER->id;
}
if (!isset($record['name'])) {
$record['name'] = 'Tag name ' . $i;
if (!isset($record['rawname'])) {
if (isset($record['name'])) {
$record['rawname'] = $record['name'];
} else {
$record['rawname'] = 'Tag name ' . $i;
}
}
if (!isset($record['rawname'])) {
$record['rawname'] = 'Raw tag name ' . $i;
// Attribute 'name' should be a lowercase version of 'rawname', if not set.
if (!isset($record['name'])) {
$record['name'] = core_text::strtolower($record['rawname']);
} else {
$record['name'] = core_text::strtolower($record['name']);
}
if (!isset($record['tagtype'])) {

View File

@ -166,6 +166,10 @@ class behat_data_generators extends behat_base {
'required' => array('qtype', 'questioncategory', 'name'),
'switchids' => array('questioncategory' => 'category', 'user' => 'createdby')
),
'tags' => array(
'datagenerator' => 'tag',
'required' => array('name')
),
);
/**