-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from Matteo-Peronnet/fix-email-reply
Add email reply-to to the user
- Loading branch information
Showing
5 changed files
with
120 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Victoire\Widget\FormBundle\Tests\Context; | ||
|
||
use Alex\MailCatcher\Behat\MailCatcherContext; | ||
|
||
class EmailContext extends MailCatcherContext | ||
{ | ||
|
||
/** | ||
* @Given /^I should see "([^"]*)" in mail reply\-to$/ | ||
*/ | ||
public function iShouldSeeInMailReplyTo($email) | ||
{ | ||
if (null === $this->currentMessage) { | ||
throw new \RuntimeException('No message selected'); | ||
} | ||
|
||
if ($this->currentMessage->getHeaders()->get('reply-to') !== $email) { | ||
throw new \InvalidArgumentException(sprintf('Unable to find reply-to header with email : "%s".', $email)); | ||
} | ||
} | ||
|
||
/** | ||
* @Given /^I should see nothing in mail reply\-to$/ | ||
*/ | ||
public function iShouldSeeNothingInMailReplyTo() | ||
{ | ||
if (null === $this->currentMessage) { | ||
throw new \RuntimeException('No message selected'); | ||
} | ||
|
||
if ($this->currentMessage->getHeaders()->has('reply-to')) { | ||
throw new \InvalidArgumentException(sprintf('Unable reply-to headers is defined')); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@mink:selenium2 @alice(Page) @reset-schema | ||
Feature: Receive an email from the form | ||
|
||
Background: | ||
Given I maximize the window | ||
And I am on homepage | ||
And I wait 3 second | ||
When I switch to "layout" mode | ||
Then I should see "New content" | ||
When I select "Form" from the "1" select of "main_content" slot | ||
And I wait 5 seconds | ||
Then I fill in "_a_static_widget_form[submitLabel]" with "send" | ||
Then I fill in "_a_static_widget_form[adminSubject]" with "Contact" | ||
|
||
Scenario: I simple a form email contact | ||
And I click the "#questions-form-list a.add_question_link" element | ||
Then I fill in "_a_static_widget_form[questions][0][title]" with "Email" | ||
And I submit the widget | ||
And I wait 5 seconds | ||
Then I switch to "readonly" mode | ||
When I fill in "cms_form_content[questions][0][]" with "[email protected]" | ||
And I press "form-1-submit" | ||
And I wait 2 second | ||
Then 1 mail should be sent | ||
When I open mail from "[email protected]" | ||
Then I should see "[email protected]" in mail | ||
And I should see "[email protected]" in mail reply-to | ||
|
||
Scenario: I simple a form without email contact | ||
And I click the "#questions-form-list a.add_question_link" element | ||
Then I fill in "_a_static_widget_form[questions][0][title]" with "Name" | ||
And I submit the widget | ||
And I wait 5 seconds | ||
Then I switch to "readonly" mode | ||
When I fill in "cms_form_content[questions][0][]" with "[email protected]" | ||
And I press "form-1-submit" | ||
And I wait 2 second | ||
Then 1 mail should be sent | ||
When I open mail from "[email protected]" | ||
Then I should see "[email protected]" in mail | ||
And I should see nothing in mail reply-to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
swiftmailer: | ||
transport: smtp | ||
host: 127.0.0.1 | ||
username: null | ||
password: null | ||
spool: { type: memory } | ||
|
||
parameters: | ||
mailer_transport: smtp | ||
mailer_port: 1025 | ||
mailer_host: 127.0.0.1 | ||
mailer_user: '' | ||
mailer_password: '' | ||
victoire_widget_form.default_email_address: "[email protected]" | ||
victoire_widget_form.default_email_label: "anakin" | ||
|
||
swiftmailer: | ||
transport: "%mailer_transport%" | ||
host: "%mailer_host%" | ||
username: "%mailer_user%" | ||
password: "%mailer_password%" | ||
port: "%mailer_port%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo ">>> Installing Mailhog" | ||
|
||
# Download binary from github | ||
wget https://github.com/mailhog/MailHog/releases/download/v1.0.0/MailHog_linux_amd64 | ||
sudo cp MailHog_linux_amd64 /usr/bin/mailhog | ||
sudo chmod +x /usr/bin/mailhog | ||
nohup mailhog > /dev/null 2>&1 & | ||
sed -i -e 's/firefox/chrome/g' behat.yml.dist | ||
echo ">>> Installing MailCatcher" | ||
|
||
sudo apt install -y build-essential libsqlite3-dev ruby-dev | ||
gem install mailcatcher | ||
echo "sendmail_path = /usr/bin/env $(which catchmail) -f 'www-data@localhost'" >> /etc/php/7.1/mods-available/mailcatcher.ini | ||
phpenmod mailcatcher | ||
/usr/bin/env $(which mailcatcher) --ip=0.0.0.0 | ||
|
||
echo ">>> Update Behat config" | ||
|
||
# Get the Namespace of EmailContext file with regular expression | ||
# Alter the namespace to remove ';' then use triple backslashes instead of a single backslash | ||
namespace="$(cat ../../../Tests/Context/EmailContext.php | sed -rn 's/namespace ((\\{1,2}\w+|\w+\\{1,2})(\w+\\{0,2})+)/\1/p' | sed -r 's/;+$//' | sed -e 's|\\|\\\\\\|g' )" | ||
# Add EmailContext path in the behat.yml.dist file to load the context | ||
sed -i "s@contexts:@contexts: \n - $namespace\\\EmailContext@" behat.yml.dist | ||
rm ../../../Tests/Context/EmailContext.php | ||
sed -i "s@extensions:@extensions: \n Alex\\\MailCatcher\\\Behat\\\MailCatcherExtension\\\Extension:\n url: http://fr.victoire.io:1080\n purge_before_scenario: true@" behat.yml.dist | ||
# Use Chrome instead of firefox | ||
sed -i -e 's/firefox/chrome/g' behat.yml.dist | ||
|
||
echo ">>> Install dev Dependencies" | ||
php -d memory_limit=-1 /usr/local/bin/composer require alexandresalome/mailcatcher |