Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion commerce_kickstart.install
Original file line number Diff line number Diff line change
Expand Up @@ -621,10 +621,14 @@ function commerce_kickstart_install() {
variable_set('node_submitted_page', FALSE);
variable_set('pathauto_node_page_pattern', '[node:title]');

// Allow visitor account creation with administrative approval
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);

// Enable default permissions for system roles.
$filtered_html_permission = filter_permission_name($filtered_html_format);
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', 'access comments', 'access checkout', 'view own commerce_order entities', 'view any commerce_product entity', $filtered_html_permission));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'access checkout', 'view own commerce_order entities', 'view any commerce_product entity', 'post comments', 'skip comment approval', $filtered_html_permission));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'access checkout', 'view own commerce_order entities', 'view any commerce_product entity', $filtered_html_permission));
//user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content', 'access comments', 'access checkout', 'view own commerce_order entities', 'view any commerce_product entity', 'post comments', 'skip comment approval', $filtered_html_permission));

// Create a default role for site administrators, with all available permissions assigned.
$admin_role = new stdClass();
Expand Down
27 changes: 27 additions & 0 deletions tests/behat/features/blog.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Feature: Blog
In order to read more about the store
As any user
I should be able to see the blog

Background:
Given I am on the homepage
When I click "Blog"
Then I should see the heading "Blog"

Scenario: Categories should pull relevant blog posts
When I click "Kickstart Tip"
Then I should see the heading "Blog - Category: Kickstart Tip"
And I should see "Social logins made simple"

Scenario: Comments should be closed for anonymous users
When I click "Social Logins Made Simple"
Then I should see the heading "Social Logins Made Simple"
Then I should see "Log in or register to post comments"

@drush
Scenario: Comments should be closed for authenticated users
When I am logged in as a user with the "authenticated user" role
When I click "Blog"
When I click "Social Logins Made Simple"
Then I should see the heading "Social Logins Made Simple"
Then I should not see "Log in or register to post comments"
19 changes: 14 additions & 5 deletions tests/behat/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Behat\Gherkin\Node\PyStringNode,
Behat\Gherkin\Node\TableNode;
use Drupal\DrupalExtension\Context\DrupalContext;
use Drupal\Component\Utility\Random;

use Symfony\Component\Process\Process;
use Behat\Behat\Context\Step\Given;
Expand Down Expand Up @@ -53,10 +54,6 @@ public function iShouldSeeTheFollowingTexts(TableNode $table) {
}
}

protected function randomString($number = 10) {
return 'abcdefghijk';
}

/**
* @Given /^I (?:should |)see the following <links>$/
*/
Expand Down Expand Up @@ -117,12 +114,24 @@ public function theFieldShouldBeOutlinedInRed($field) {
*/
public function iFillInWithRandomText($label) {
// A @Tranform would be more elegant.
$randomString = $this->randomString(10);
$random = new Random;
$randomString = $random->name(10);

$step = "I fill in \"$label\" with \"$randomString\"";
return new Then($step);
}

/**
* @Given /^I fill in "([^"]*)" with random email$/
*/
public function iFillInWithRandomEmail($label) {
// A @Tranform would be more elegant.
$random = new Random;
$randomString = $random->name(10);
$step = "I fill in \"$label\" with \"$randomString@example.com\"";
return new Then($step);
}

/**
* Helper function to fetch user details stored in behat.local.yml.
*
Expand Down
59 changes: 58 additions & 1 deletion tests/behat/features/checkout.feature
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,21 @@ Feature: Checkout and pay
And I press "Update cart"
Then I should see "Your shopping cart has been updated."
And I should see "$16.00"

@javascript
Scenario: An existing user should be able to checkout
Then I should see "Shopping cart"
Then I should see the following <texts>
| texts |
| $8.00 |
| SKU: MG1-BLU-OS |
And the "edit_quantity[0]" field should contain "1"
When I fill in "2" for "edit_quantity[0]"
And I press "Update cart"
Then I should see "Your shopping cart has been updated."
And I should see "$16.00"
When I press "Checkout"
Then I should see "I don't have an account"
Then I should see the heading "Login"
When I fill in "admin" for "Username"
And I fill in "admin" for "Password"
And I press "Log in"
Expand Down Expand Up @@ -57,3 +70,47 @@ Feature: Checkout and pay
And I should see "Your order number is"
And I should see "You can view your order on your account page when logged in"
And I should see "Return to the front page"

@javascript
Scenario: An anonymous user can create account during checkout
When I press "Checkout"
Then I should see "You need to be logged in to be able to checkout."
Then I should see the heading "I don't have an account"
When I click "Create an account"
Then I should see the heading "Register"
Given I fill in "Username" with random text
And I fill in "E-mail address" with random email
When I fill in "Password" with "myawesomepass"
And I fill in "Confirm password" with "myawesomepass"
And I press "Create new account"
Then I should see "Registration successful. You are now logged in."
Then I should see "Checkout"
Then I should see the following <texts>
| texts |
| $8.00 |
| Coffee Mug 1 |
| Billing information |
When I select "United States" from "Country"
Given I wait for AJAX loading to finish
When I fill in the following:
| Full name | My full name |
| Address 1 | My address |
| City | My city |
| ZIP Code | 90120 |
And I select "California" from "State"
And I press "Continue to next step"
# Just choose the default shipping method
And I press "Continue to next step"
Then I should see "Review order"
# The default shipping method
And I should see "Express shipping: 1 business day"
# Order total
And I should see "$23.00"
When I fill in "4111111111111111" for "Card number"
And I select "03" from "commerce_payment[payment_details][credit_card][exp_month]"
And I select "24" from "commerce_payment[payment_details][credit_card][exp_year]"
And I press "Continue to next step"
Then I should see "Checkout complete"
And I should see "Your order number is"
And I should see "You can view your order on your account page when logged in"
And I should see "Return to the front page"