Skip to content

Commit

Permalink
Merge branch 'wip-MDL-50874-master' of https://github.com/marinaglanc…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Jul 28, 2015
2 parents 335adbe + 9a7e398 commit 8a53c3f
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 4 deletions.
51 changes: 51 additions & 0 deletions blocks/blog_tags/tests/behat/blogtag.feature
@@ -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
64 changes: 64 additions & 0 deletions blocks/tags/tests/behat/coursetags.feature
@@ -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
59 changes: 59 additions & 0 deletions blocks/tags/tests/behat/tagcloud.feature
@@ -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
15 changes: 11 additions & 4 deletions lib/testing/generator/data_generator.php
Expand Up @@ -792,12 +792,19 @@ public function create_tag($record = null) {
$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'])) {
Expand Down
4 changes: 4 additions & 0 deletions lib/tests/behat/behat_data_generators.php
Expand Up @@ -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')
),
);

/**
Expand Down

0 comments on commit 8a53c3f

Please sign in to comment.