Skip to content

Commit 0a5ab99

Browse files
kilipSam Tuke
authored and
Sam Tuke
committed
improved behat smtp feature, fix travis build error
1 parent caf8e33 commit 0a5ab99

File tree

9 files changed

+120
-222
lines changed

9 files changed

+120
-222
lines changed

.travis.yml

+18-14
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ cache:
77
matrix:
88
include:
99
- php: '5.4'
10-
env: BROWSER=goutte
11-
- php: '5.5'
12-
env: BROWSER=goutte
10+
env: BROWSER=goutte TAGS="~javascript && ~@first-run && ~@wip"
11+
- php: '5.5'
12+
env: BROWSER=goutte TAGS="~javascript && ~@first-run && ~@wip"
1313
- php: '5.6'
14-
env: BROWSER=goutte
14+
env: BROWSER=goutte TAGS="~javascript && ~@first-run && ~@wip"
1515
- php: '7.0'
16-
env: BROWSER=goutte
16+
env: BROWSER=goutte TAGS="~javascript && ~@first-run && ~@wip"
1717
- php: '7.1'
18-
env: BROWSER=goutte
18+
env: BROWSER=goutte TAGS="~javascript && ~@first-run && ~@wip"
1919
- php: '7.1'
20-
env: BROWSER=chrome
20+
env: BROWSER=chrome TAGS="~@first-run && ~@wip"
2121
- php: '7.2'
22-
env: BROWSER=goutte
22+
env: BROWSER=goutte TAGS="~javascript && ~@first-run && ~@wip"
2323
- php: '7.2'
24-
env: BROWSER=chrome
24+
env: BROWSER=chrome TAGS="~@first-run && ~@wip"
2525

2626

2727
notifications:
@@ -44,7 +44,8 @@ install:
4444
- composer install --prefer-dist --no-interaction
4545

4646
# start php server for non php >=5.4 version
47-
- cp -fv ./tests/config.php.dist public_html/lists/config/config.php
47+
- cp -fv tests/travis-ci/behat.yml behat.yml
48+
- cp -fv tests/travis-ci/config.php public_html/lists/config/config.php
4849
- php -S localhost:8000 -t public_html > /dev/null 2>&1 &
4950

5051
# start selenium and php server
@@ -55,8 +56,6 @@ install:
5556

5657
# setup database and phplist
5758
- mkdir -p build/screenshot
58-
- cp -f tests/travis-ci/behat.yml behat.yml
59-
- cp -f tests/travis-ci/config.php public_html/lists/config/config.php
6059
- cd public_html/lists/admin/ui/ && wget https://github.com/phpList/phplist-ui-bootlist/archive/master.tar.gz
6160
&& tar -xzf master.tar.gz && mv phplist-ui-bootlist-master phplist-ui-bootlist &&
6261
rm master.tar.gz && cd ../../../../
@@ -69,19 +68,24 @@ install:
6968

7069
before_script:
7170
- sudo service postfix stop
71+
- mkdir -p build/mails
72+
- cd build/mails
7273
- smtp-sink -d "%d.%H.%M.%S" localhost:2500 1000 &
74+
- cd ${TRAVIS_BUILD_DIR}
7375

7476
script:
7577
# check syntax
7678
- ./vendor/bin/phpLint ./public_html
7779

7880
# run setup feature first to create database
79-
- ./vendor/bin/behat -fprogress -p $BROWSER --strict --tags=@first-run
81+
- ./vendor/bin/behat -n -fprogress -p $BROWSER --strict --tags=@first-run
8082

8183
# run all feature except @first-run
82-
- ./vendor/bin/behat -fprogress -p $BROWSER --strict --tags="~@first-run && ~@wip"
84+
- ./vendor/bin/behat -n -fprogress -p $BROWSER --strict --tags="${TAGS}"
8385
addons:
8486
chrome: stable
8587

8688
after_failure:
89+
- ls -l build/mails
90+
- ls -l
8791
- IMGUR_CLIENT_ID=bec050c54e1bb52 ./bin/imgur-uploader.sh build/screenshot/*.png

default.behat.yml

+14-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ default:
99
- FeatureContext:
1010
# Set database access credentials
1111
database:
12-
host: localhost
12+
host: 127.0.0.1
1313
user: phplist
1414
password: phplist
1515
name: phplistdb
1616
# Set admin user login credentials
1717
admin:
1818
username: admin
1919
password: Mypassword123+
20+
- MailContext:
21+
mail_dir: %paths.base%/build/mails
22+
- SubscriberContext
23+
- UserContext
2024
extensions:
2125
Bex\Behat\ScreenshotExtension:
2226
image_drivers:
@@ -27,21 +31,26 @@ default:
2731
clear_screenshot_directory: true
2832

2933
Behat\MinkExtension:
30-
base_url: 'http://localhost:8000'
34+
base_url: 'http://127.0.0.1:8000'
3135
default_session: goutte
3236
goutte: ~
3337
sessions:
3438
default:
3539
goutte: ~
3640
chrome:
3741
selenium2:
42+
browser: chrome
3843
capabilities:
44+
browserName: chrome
3945
browser: chrome
46+
version: ""
4047
chrome:
4148
switches:
42-
- "--window-size=2000,2000"
43-
- "--disable-gpu"
4449
- "--headless"
50+
- "--disable-gpu"
51+
- "--window-size=2000,2000"
52+
- "--lang=en"
53+
- "--no-sandbox"
4554

4655
firefox:
4756
selenium2:
@@ -64,4 +73,4 @@ firefox:
6473
extensions:
6574
Behat\MinkExtension:
6675
default_session: firefox
67-
browser_name: firefox
76+
browser_name: firefox

public_html/lists/config/config.php

+4-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
// what is your Mysql database server hostname
19-
$database_host = 'localhost';
19+
$database_host = '127.0.0.1';
2020

2121
// what is the name of the database we are using
2222
$database_name = 'phplistdb';
@@ -30,15 +30,10 @@
3030
// if you have an SMTP server, set it here. Otherwise it will use the normal php mail() function
3131
//# if your SMTP server is called "smtp.mydomain.com" you enter this below like this:
3232
//#
33-
//# define("PHPMAILERHOST",'smtp.mydomain.com');
33+
define("PHPMAILERHOST",'127.0.0.1');
34+
define('PHPMAILERPORT',2500);
3435

35-
define('PHPMAILERHOST', '');
36-
37-
// if TEST is set to 1 (not 0) it will not actually send ANY messages, but display what it would have sent
38-
// this is here, to make sure you edited the config file and mails are not sent "accidentally"
39-
// on unmanaged systems
40-
41-
define('TEST', 1);
36+
define('TEST', 0);
4237

4338
/*
4439

tests/config.php.dist

-117
This file was deleted.

tests/features/bootstrap/SubscriberContext.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Behat\Behat\Context\Context;
66
use Behat\Gherkin\Node\TableNode;
7+
use Behat\Gherkin\Node\PyStringNode;
78
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
89

910
class SubscriberContext implements Context
@@ -27,16 +28,16 @@ public function beforeScenario(BeforeScenarioScope $scope)
2728
* @param array $table
2829
*
2930
* @Given /I have "(.*)" list with the following subscribers:/
31+
* @throws Exception
3032
*/
31-
public function iHaveSubscribersForList($list,TableNode $table)
33+
public function iHaveSubscribersForList($list, PyStringNode $stringNode)
3234
{
33-
35+
$rows = $stringNode->getStrings();
3436
$db = $this->featureContext->getMysqli();
35-
$rows = $table->getRows();
3637
$list = $this->iHaveList($list);
3738
$table = 'phplist_listuser';
3839
foreach($rows as $row){
39-
$subscriber = $this->iHaveSubscriber($row[0]);
40+
$subscriber = $this->iHaveSubscriber($row);
4041

4142
$select = sprintf(
4243
'SELECT userid,listid from %s where userid=%s and listid=%s',
+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
22

33
$lib = __DIR__.'/../../../public_html/lists/admin';
4+
5+
include_once $lib.'/inc/random_compat/random.php';
46
include_once $lib.'/inc/UUID.php';

tests/features/smtp.feature

+5-8
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,16 @@ Feature: SMTP Mail test
2121
And I should have email sent from "From Me"
2222
And I should have email sent to address "[email protected]"
2323
And I should have email sent contains "This is the Content of the Campaign"
24-
# @todo: remove this failed test before pull request merged
25-
And I should have email sent with the following:
26-
| from | Failed Name |
27-
| from address | fail.from@mydomain.com |
28-
| to address | fail.to@pplist.dev |
2924

3025
@emptySentMail @javascript
3126
Scenario: Sending campaign with list subscribers
3227
Given I have logged in as an administrator
3328
And I have "smtp" list with the following subscribers:
34-
| test1@phplist.dev |
35-
| test2@phplist.dev |
36-
| test3@phplist.dev |
29+
"""
30+
31+
32+
33+
"""
3734
And I follow "Campaigns"
3835
And I follow "Send a campaign"
3936
And I follow "start a new campaign"

0 commit comments

Comments
 (0)