the email body starts with Hi Bob Smith and this is formed with tokens, we want to test that these tokens are replaced in the email body. We do this as we use tokens to form the email body and want to test that the tokens are replaced with the real name. We then log-in as the '_bob' user, edit our profile and set the first and last name fields to Bob and Smith respectively. One of the users '_boss' has the 'manage points levels' role, this is used in the Rules configuration to send out the admin emails (this uses a custom-step definition left as an exercise to the reader). They receive 100 points for creating their account and 2 points per comment, so in the background we create two users and set their initial points level to Bronze. On the site, users start with 'Bronze' points level and move to 'Silver' once they reach 1000 points. Then the email to should contain "Hi Bob Smith"Īnd the email should contain "Congratulations - you've just reached 1000 points"Īnd the email to should contain "User _bob reached Silver points level" When I enter "I have something to say" for "Comment" Given I am viewing an "article" node with the title "Please comment on this." Given I have just earned "898" points in "General" category # 100 points for signing up + 898 + 2 for comment = 1000. | name | mail | field_user_points_level |Īnd user "_boss" has the "manage point levels" roleĪnd the test email system is Silver points level I can be awarded points levels after reaching a certain point To encourage users to participate in the site So our feature looks as follows: Feature: Passing points levels Don't worry if they don't exist, Behat will give you skeleton code to add to your FeatureContext class. Testing email with BehatĪs with any Behat test, start by defining the step-definitions. The default mail system is DefaultMailSystem found in, however, Drupal also ships with a test mail handler in the form of TestingMailSystem. The test mail system just collects all sent email into the drupal_test_email_collector variable, allowing the email content to be examined for test purposes. This is configurable via the mail_system variable. With that template in place, you can now create a hello-world.twig template in your templates/ folder, which extends your _html5.In Drupal 7 mail handling is done via the mail system. (We’re using the attr function to convert that hash into a list of HTML attributes.) It gives nested templates the ability to set custom attributes on the element, by defining a bodyAttributes hash.It allows nested templates to define a docTitle variable, which will become the value, and defaults to the site name if that’s not defined.It defines head and body blocks, which give nested templates a way to override the contents of the and elements.This template is pretty worthless on its own, but it provides a framework for nested templates to take advantage of: At its outer edges you will find left and right curly braces ( The raw HTML code will be output to the browser without any tampering.Īll Twig code follows a basic pattern that separates it from the surrounding HTML. When Twig loads a template, the first thing it will do is separate the raw HTML code from the Twig code. Twig templates are HTML files that are sprinkled with bits of Twig code. Twig (opens new window) is a fast and powerful templating system, commonly used to power front-end views in content management systems like Craft, Drupal, and WordPress (via the Timber (opens new window) plugin).
0 Comments
Leave a Reply. |