Initial acceptance testing setup
[MAILPOET-997]
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,7 +3,6 @@ TODO
|
||||
composer.phar
|
||||
/vendor
|
||||
tests/_output/*
|
||||
tests/acceptance.suite.yml
|
||||
tests/_support/_generated/*
|
||||
node_modules
|
||||
.env
|
||||
|
39
Dockerfile
Normal file
39
Dockerfile
Normal file
@ -0,0 +1,39 @@
|
||||
FROM php:5.6-cli
|
||||
|
||||
ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install \
|
||||
git \
|
||||
zlib1g-dev \
|
||||
libssl-dev \
|
||||
mysql-client \
|
||||
sudo less \
|
||||
--no-install-recommends && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
||||
docker-php-ext-install bcmath zip mysqli pdo pdo_mysql && \
|
||||
echo "date.timezone = UTC" >> /usr/local/etc/php/php.ini && \
|
||||
curl -sS https://getcomposer.org/installer | php -- \
|
||||
--filename=composer \
|
||||
--install-dir=/usr/local/bin && \
|
||||
composer global require --optimize-autoloader "hirak/prestissimo" && \
|
||||
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && \
|
||||
chmod +x wp-cli.phar && \
|
||||
mv wp-cli.phar /usr/local/bin/wp
|
||||
|
||||
# Prepare application
|
||||
WORKDIR /repo
|
||||
|
||||
# Install vendor
|
||||
COPY ./composer.json /repo/composer.json
|
||||
|
||||
# Add source-code
|
||||
COPY . /repo
|
||||
|
||||
WORKDIR /wp-core/wp-content/plugins/mailpoet
|
||||
ENV WP_TEST_PATH=/wp-core
|
||||
|
||||
ADD docker-entrypoint.sh /
|
||||
|
||||
RUN ["chmod", "+x", "/docker-entrypoint.sh"]
|
18
README.md
18
README.md
@ -180,3 +180,21 @@ Run 'svn copy ...' to tag the release
|
||||
It's quite literal: you can review the changes to be pushed and if you're satisfied, run the suggested command to finish the release publishing process.
|
||||
|
||||
If you're confident, execute `./do publish --force` and your release will be published to the remote SVN repository without manual intervention (automatically). For easier authentication you might want to set `WP_SVN_USERNAME` and `WP_SVN_PASSWORD` environment variables.
|
||||
|
||||
# Acceptance testing
|
||||
|
||||
We are using Gravity Flow plugin's setup as an example for our acceptance test suite: https://www.stevenhenty.com/learn-acceptance-testing-deeply/
|
||||
|
||||
From the article above:
|
||||
|
||||
_Windows users only: enable hard drive sharing in the Docker settings._
|
||||
|
||||
The browser runs in a docker container. You can use a VNC client to watch the test run, follow instructions in official
|
||||
repo: https://github.com/SeleniumHQ/docker-selenium
|
||||
If you’re on a Mac, you can open vnc://localhost:5900 in Safari to watch the tests running in Chrome. If you’re on Windows, you’ll need a VNC client. Password: secret.
|
||||
|
||||
|
||||
To run tests:
|
||||
```sh
|
||||
$ ./do test:acceptance
|
||||
```
|
20
RoboFile.php
20
RoboFile.php
@ -154,9 +154,9 @@ class RoboFile extends \Robo\Tasks {
|
||||
|
||||
function testUnit($opts=['file' => null, 'xml' => false]) {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
|
||||
|
||||
$command = 'vendor/bin/codecept run unit -f '.(($opts['file']) ? $opts['file'] : '');
|
||||
$command = 'vendor/bin/codecept run unit -c codeception.unit.yml -f '.(($opts['file']) ? $opts['file'] : '');
|
||||
|
||||
if($opts['xml']) {
|
||||
$command .= ' --xml';
|
||||
@ -166,9 +166,9 @@ class RoboFile extends \Robo\Tasks {
|
||||
|
||||
function testCoverage($opts=['file' => null, 'xml' => false]) {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
|
||||
$command = join(' ', array(
|
||||
'vendor/bin/codecept run',
|
||||
'vendor/bin/codecept run -c codeception.unit.yml ',
|
||||
(($opts['file']) ? $opts['file'] : ''),
|
||||
'--coverage',
|
||||
($opts['xml']) ? '--coverage-xml' : '--coverage-html'
|
||||
@ -201,9 +201,9 @@ class RoboFile extends \Robo\Tasks {
|
||||
|
||||
function testDebug($opts=['file' => null, 'xml' => false]) {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
|
||||
|
||||
$command = 'vendor/bin/codecept run unit --debug -f '.(($opts['file']) ? $opts['file'] : '');
|
||||
$command = 'vendor/bin/codecept run unit -c codeception.unit.yml --debug -f '.(($opts['file']) ? $opts['file'] : '');
|
||||
|
||||
if($opts['xml']) {
|
||||
$command .= ' --xml';
|
||||
@ -211,10 +211,14 @@ class RoboFile extends \Robo\Tasks {
|
||||
return $this->_exec($command);
|
||||
}
|
||||
|
||||
function testAcceptance() {
|
||||
return $this->_exec('docker-compose run codeception --steps --debug -vvv');
|
||||
}
|
||||
|
||||
function testFailed() {
|
||||
$this->loadEnv();
|
||||
$this->_exec('vendor/bin/codecept build');
|
||||
return $this->_exec('vendor/bin/codecept run -g failed');
|
||||
$this->_exec('vendor/bin/codecept build -c codeception.unit.yml');
|
||||
return $this->_exec('vendor/bin/codecept run -c codeception.unit.yml -g failed');
|
||||
}
|
||||
|
||||
function qa() {
|
||||
|
50
codeception.acceptance.yml
Normal file
50
codeception.acceptance.yml
Normal file
@ -0,0 +1,50 @@
|
||||
actor: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
log: tests/_output
|
||||
data: tests/_data
|
||||
support: tests/_support
|
||||
envs: tests/_envs
|
||||
settings:
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
log: true
|
||||
strict_xml: true
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
||||
modules:
|
||||
config:
|
||||
WPWebDriver:
|
||||
host: chrome
|
||||
url: 'http://wordpress'
|
||||
browser: chrome
|
||||
port: 4444
|
||||
window_size: '1024x768'
|
||||
restart: true
|
||||
wait: 0
|
||||
adminUsername: admin
|
||||
adminPassword: password
|
||||
adminPath: /wp-admin
|
||||
WPLoader:
|
||||
wpRootFolder: /wp-core
|
||||
dbName: wordpress
|
||||
dbHost: mysql
|
||||
dbUser: wordpress
|
||||
dbPassword: wordpress
|
||||
wpDebug: false
|
||||
tablePrefix: wp_
|
||||
domain: wordpress
|
||||
plugins: ['mailpoet/mailpoet.php']
|
||||
activatePlugins: ['mailpoet/mailpoet.php']
|
||||
coverage:
|
||||
enabled: true
|
||||
whitelist:
|
||||
include:
|
||||
- lib/*
|
||||
exclude:
|
||||
- lib/Config/PopulatorData/*
|
||||
- lib/Util/Sudzy/*
|
||||
- lib/Util/CSS.php
|
||||
- lib/Util/Helpers.php
|
||||
- lib/Util/XLSXWriter.php
|
@ -21,6 +21,28 @@ modules:
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
WPLoader:
|
||||
wpRootFolder: /wp-core
|
||||
dbName: wordpress
|
||||
dbHost: mysql
|
||||
dbUser: wordpress
|
||||
dbPassword: wordpress
|
||||
wpDebug: false
|
||||
tablePrefix: wp_
|
||||
domain: wordpress
|
||||
plugins: ['mailpoet/mailpoet.php']
|
||||
activatePlugins: ['mailpoet/mailpoet.php']
|
||||
WPWebDriver:
|
||||
host: chrome
|
||||
url: 'http://wordpress'
|
||||
browser: chrome
|
||||
port: 4444
|
||||
window_size: '1024x768'
|
||||
restart: true
|
||||
wait: 0
|
||||
adminUsername: admin
|
||||
adminPassword: password
|
||||
adminPath: /wp-admin
|
||||
coverage:
|
||||
enabled: true
|
||||
whitelist:
|
@ -24,6 +24,8 @@
|
||||
"codeception/verify": "^0.3.3",
|
||||
"consolidation/robo": "^1.0.5",
|
||||
"henrikbjorn/lurker": "^1.2",
|
||||
"lucatume/wp-browser": "1.19.12",
|
||||
"phpunit/phpunit": "4.8.21",
|
||||
"vlucas/phpdotenv": "^2.4.0",
|
||||
"umpirsky/twig-gettext-extractor": "1.1.*",
|
||||
"raveren/kint": "^1.0",
|
||||
|
2250
composer.lock
generated
2250
composer.lock
generated
File diff suppressed because it is too large
Load Diff
58
docker-compose.yml
Normal file
58
docker-compose.yml
Normal file
@ -0,0 +1,58 @@
|
||||
version: '2.1'
|
||||
|
||||
services:
|
||||
codeception:
|
||||
build: .
|
||||
depends_on:
|
||||
- wordpress
|
||||
volumes:
|
||||
- ./:/project
|
||||
- wp-core:/wp-core
|
||||
- ./:/wp-core/wp-content/plugins/mailpoet
|
||||
entrypoint: /docker-entrypoint.sh
|
||||
|
||||
wordpress:
|
||||
build: ./tests/wordpressDockerfile
|
||||
image: wordpress:latest
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
chrome:
|
||||
condition: service_healthy
|
||||
volumes:
|
||||
- wp-core:/var/www/html
|
||||
- ./:/var/www/html/wp-content/plugins/mailpoet
|
||||
ports:
|
||||
- 8080:80
|
||||
environment:
|
||||
WORDPRESS_DB_PASSWORD: wordpress
|
||||
|
||||
mysql:
|
||||
image: mysql:5.6
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: wordpress
|
||||
MYSQL_DATABASE: wordpress
|
||||
MYSQL_USER: wordpress
|
||||
MYSQL_PASSWORD: wordpress
|
||||
healthcheck:
|
||||
test: "mysql -uwordpress -pwordpress -e 'SELECT 1'"
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
|
||||
chrome:
|
||||
environment:
|
||||
- DBUS_SESSION_BUS_ADDRESS=/dev/null
|
||||
volumes:
|
||||
- /dev/shm:/dev/shm
|
||||
image: selenium/standalone-chrome-debug
|
||||
ports:
|
||||
- '4444'
|
||||
- '5900:5900'
|
||||
healthcheck:
|
||||
test: "wget -O/dev/null http://localhost:4444"
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
volumes:
|
||||
wp-core:
|
28
docker-entrypoint.sh
Normal file
28
docker-entrypoint.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Allows WP CLI to run with the right permissions.
|
||||
wp-su() {
|
||||
sudo -E -u www-data wp "$@"
|
||||
}
|
||||
|
||||
# Make sure permissions are correct.
|
||||
cd /wp-core
|
||||
chown www-data:www-data wp-content/plugins
|
||||
chmod 755 wp-content/plugins
|
||||
|
||||
# Make sure WordPress is installed.
|
||||
if ! $(wp-su core is-installed); then
|
||||
|
||||
echo "Installing WordPress"
|
||||
|
||||
wp-su core install --url=wordpress --title=tests --admin_user=admin --admin_email=test@test.com
|
||||
|
||||
echo "Configuring WordPress"
|
||||
# The development version of Gravity Flow requires SCRIPT_DEBUG
|
||||
wp-su core config --dbhost=mysql --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --extra-php="define( 'SCRIPT_DEBUG', true );" --force
|
||||
|
||||
fi
|
||||
|
||||
cd /wp-core/wp-content/plugins/mailpoet
|
||||
|
||||
/repo/vendor/bin/codecept run acceptance -c codeception.acceptance.yml $@
|
@ -29,4 +29,29 @@ class AcceptanceTester extends \Codeception\Actor {
|
||||
$this->click('Log In');
|
||||
$this->saveSessionSnapshot('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
public function logOut() {
|
||||
$I = $this;
|
||||
$I->amOnPage('/wp-login.php?action=logout');
|
||||
$I->click('log out');
|
||||
$I->wait(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to the specified Mailpoet page in the admin.
|
||||
*
|
||||
* @param string $page The page to visit e.g. Inbox or Status
|
||||
*/
|
||||
public function amOnMailpoetPage($page) {
|
||||
$I = $this;
|
||||
$I->amOnPage('/wp-admin');
|
||||
$I->click('MailPoet');
|
||||
$I->waitForText($page, 3);
|
||||
$I->click($page);
|
||||
$I->waitForText($page, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
6
tests/acceptance.suite.yml
Normal file
6
tests/acceptance.suite.yml
Normal file
@ -0,0 +1,6 @@
|
||||
actor: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
- \Helper\Acceptance
|
||||
- WPLoader
|
||||
- WPWebDriver
|
15
tests/acceptance/NewsletterListingCept.php
Normal file
15
tests/acceptance/NewsletterListingCept.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/*
|
||||
* Test summary: Test Newsletters page works
|
||||
*
|
||||
* Test details:
|
||||
* - Open newsletters from the menu
|
||||
*/
|
||||
$I = new AcceptanceTester($scenario);
|
||||
$I->wantTo('Open newsletters page');
|
||||
|
||||
$I->loginAsAdmin();
|
||||
$I->seeInCurrentUrl('/wp-admin/');
|
||||
// Go to Status
|
||||
$I->amOnMailpoetPage('Emails');
|
||||
$I->waitForElement('#newsletters_container', 3);
|
1
tests/acceptance/_bootstrap.php
Normal file
1
tests/acceptance/_bootstrap.php
Normal file
@ -0,0 +1 @@
|
||||
<?php
|
@ -3,6 +3,8 @@
|
||||
# Suite for unit (internal) tests.
|
||||
|
||||
class_name: UnitTester
|
||||
settings:
|
||||
bootstrap: _bootstrap.php
|
||||
modules:
|
||||
enabled:
|
||||
- Asserts
|
||||
|
13
tests/wordpressDockerfile/Dockerfile
Normal file
13
tests/wordpressDockerfile/Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM wordpress:latest
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install \
|
||||
zlib1g-dev \
|
||||
sudo less \
|
||||
--no-install-recommends && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
|
||||
docker-php-ext-install bcmath zip mysqli pdo pdo_mysql && \
|
||||
echo "date.timezone = UTC" >> /usr/local/etc/php/php.ini && \
|
||||
mkdir -p /var/www/html/wp-content/uploads/mailpoet/cache && \
|
||||
chmod 777 /var/www/html/wp-content/uploads/mailpoet/cache
|
Reference in New Issue
Block a user