Closed indietravel closed 6 years ago
Thanks for reporting the issue, I've still not looked into this but am very curious to do. Did you make any progress or found out something new?
Sadly, no progress. I can run basic tests from outside Docker, looking at the front end of localhost, but I cannot run them from inside docker to do proper tests. On Thu, 1 Mar 2018 at 21:39, theAverageDev (Luca Tumedei) < notifications@github.com> wrote:
Thanks for reporting the issue, I've still not looked into this but am very curious to do. Did you make any progress or found out something new?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucatume/wp-browser/issues/140#issuecomment-369516254, or mute the thread https://github.com/notifications/unsubscribe-auth/AByOfvq3GwAXdSxvMl9Ig5VXhv84OrDfks5tZ7PAgaJpZM4SKM99 .
-- Craig Martin Owner/Director, Performance Foundry http://performancefoundry.com
Owner, Indie Travel Media http://indietravelmedia.com
Ok, thanks for the update anyway. I will take some time, in the weekend, to install your setup and run some test and get back to you. Did you do any relevant modification to the local-docker setup I should be aware of?
Ok, I've installed the setup and spun it up.
I've run all the commands below from within the php_fpm
container of the stack:
lucatume/wp-browser:^2.0
and vlucas/phpdotenv
as dev dependenciestests
database that I will use to run the wpunit
tests; mysql -u root -p -h mysql -e "create database if not exists tests;"
, root password is password
(from the docker-compose.yml
file)vendor/bin/codecept init wpbrowser
; relevant answers are http://nginx
as URL and /var/ww/html
as WP root folder.env
based configuration; to do so I've added this line in the codeception.yml
file:
params:
- .env
This is my .env
file to run the tests from within the Docker php_fpm
container:
ROOT_FOLDER="/var/www/html"
URL="http://nginx"
DOMAIN="nginx"
DB_HOST="mysql"
DB_NAME="wordpress"
DB_USER="root"
DB_PASSWORD="password"
ADMIN_USERNAME="admin"
ADMIN_PASSWORD="admin"
TEST_DB_NAME="tests"
The codeception.yml
file:
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
commands:
- Codeception\Command\GenerateWPUnit
- Codeception\Command\GenerateWPRestApi
- Codeception\Command\GenerateWPRestController
- Codeception\Command\GenerateWPRestPostTypeController
- Codeception\Command\GenerateWPAjax
- Codeception\Command\GenerateWPCanonical
- Codeception\Command\GenerateWPXMLRPC
- Codeception\Command\DbSnapshot
- tad\Codeception\Command\SearchReplace
params:
- .env
And this is the tests/acceptance.suite.yml
file:
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WPWebDriver or WPBrowser.
# Use WPDb to set up your initial database fixture.
# If you need both WPWebDriver and WPBrowser tests - create a separate suite.
actor: AcceptanceTester
modules:
enabled:
- WPDb
- WPBrowser
- \Helper\Acceptance
config:
WPDb:
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%'
user: '%DB_USER%'
password: '%DB_PASSWORD%'
dump: 'tests/_data/dump.sql'
populate: true #import the dump before the tests
cleanup: true #import the dump between tests
url: '%URL%'
urlReplacement: true #replace the hardcoded dump URL with the one above
tablePrefix: 'wp_'
WPBrowser:
url: '%URL%'
adminUsername: '%ADMIN_USERNAME%'
adminPassword: '%ADMIN_PASSWORD%'
adminPath: '/wp-admin'
The tests/functional.suite.yml
file:
# Codeception Test Suite Configuration
#
# Suite for functional tests
# Emulate web requests and make WordPress process them
actor: FunctionalTester
modules:
enabled:
- WPDb
- WordPress
- Asserts
- \Helper\Functional
config:
WPDb:
dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%'
user: '%DB_USER%'
password: '%DB_PASSWORD%'
dump: 'tests/_data/dump.sql'
populate: true
cleanup: true
url: '%URL%'
urlReplacement: true
tablePrefix: 'wp_'
WordPress:
depends: WPDb
wpRootFolder: '%ROOT_FOLDER%'
adminUsername: '%ADMIN_USERNAME%'
adminPassword: '%ADMIN_PASSWORD%'
adminPath: '/wp-admin'
The tests/wpunit.suite.yml
file:
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests that require WordPress functions and classes.
actor: WpunitTester
modules:
enabled:
- WPLoader
- \Helper\Wpunit
config:
WPLoader:
wpRootFolder: "%ROOT_FOLDER%"
dbName: "%TEST_DB_NAME%"
dbHost: "%DB_HOST%"
dbUser: "%DB_USER%"
dbPassword: "%DB_PASSWORD%"
tablePrefix: "wp_"
domain: "%DOMAIN%"
adminEmail: "amdin@wplocal.local"
title: "Test"
plugins: ['test-plugin/plugin.php']
activatePlugins: ['test-plugin/plugin.php']
I had no issues running this test:
<?php
class WPFirstCest {
/**
* It should be able to reach the homepage
*
* @test
*/
public function should_be_able_to_reach_the_homepage( AcceptanceTester $I ) {
$I->havePostInDatabase(['post_title' => 'A test post']);
$I->amOnPage( '/' );
$I->see('A test post');
}
}
Let me know if this helps you.
Unfortunately a busted arm has stopped me from coming back to this in a timely manner. I’ll feed back as soon as I can. On Sun, 4 Mar 2018 at 03:53, theAverageDev (Luca Tumedei) < notifications@github.com> wrote:
Ok, I've installed the setup and spun it up.
I've run all the commands below from within the php_fpm container of the stack:
I've required lucatume/wp-browser:^2.0 and vlucas/phpdotenv as dev dependencies
I've created the tests databasethat I will use to run thewpunit tests;mysql -u root -p -h mysql -e "create database if not exists tests;", root password ispassword(from thedocker-compose.yml` file)
I've bootstrapped wp-browser with vendor/bin/codecept init wpbrowser; relevant answers are http://nginx as URL and /var/ww/html as WP root folder
I've modified the bootstrapped suites configuration files to use the .env based configuration; to do so I've added this line in the codeception.yml file:
params:
- .env
I've modified all the suites configuration files to use the env placeholders (see below).
This is my .env file to run the tests from within the Docker php_fpm container:
ROOT_FOLDER="/var/www/html" URL="http://nginx" DOMAIN="nginx" DB_HOST="mysql" DB_NAME="wordpress" DB_USER="root" DB_PASSWORD="password" ADMIN_USERNAME="admin" ADMIN_PASSWORD="admin" TEST_DB_NAME="tests"
The codeception.yml file:
paths: tests: tests output: tests/_output data: tests/_data support: tests/_support envs: tests/_envsactor_suffix: Testerextensions: enabled:
- Codeception\Extension\RunFailed commands:
- Codeception\Command\GenerateWPUnit
- Codeception\Command\GenerateWPRestApi
- Codeception\Command\GenerateWPRestController
- Codeception\Command\GenerateWPRestPostTypeController
- Codeception\Command\GenerateWPAjax
- Codeception\Command\GenerateWPCanonical
- Codeception\Command\GenerateWPXMLRPC
- Codeception\Command\DbSnapshot
- tad\Codeception\Command\SearchReplaceparams:
- .env
And this is the tests/acceptance.suite.yml file:
Codeception Test Suite Configuration## Suite for acceptance tests.# Perform tests in browser using the WPWebDriver or WPBrowser.# Use WPDb to set up your initial database fixture.# If you need both WPWebDriver and WPBrowser tests - create a separate suite.
actor: AcceptanceTestermodules: enabled:
- WPDb
- WPBrowser
- \Helper\Acceptance config: WPDb: dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%' user: '%DB_USER%' password: '%DB_PASSWORD%' dump: 'tests/data/dump.sql' populate: true #import the dump before the tests cleanup: true #import the dump between tests url: '%URL%' urlReplacement: true #replace the hardcoded dump URL with the one above tablePrefix: 'wp' WPBrowser: url: '%URL%' adminUsername: '%ADMIN_USERNAME%' adminPassword: '%ADMIN_PASSWORD%' adminPath: '/wp-admin'
The tests/functional.suite.yml file:
Codeception Test Suite Configuration## Suite for functional tests# Emulate web requests and make WordPress process them
actor: FunctionalTestermodules: enabled:
- WPDb
- WordPress
- Asserts
- \Helper\Functional config: WPDb: dsn: 'mysql:host=%DB_HOST%;dbname=%DB_NAME%' user: '%DB_USER%' password: '%DB_PASSWORD%' dump: 'tests/data/dump.sql' populate: true cleanup: true url: '%URL%' urlReplacement: true tablePrefix: 'wp' WordPress: depends: WPDb wpRootFolder: '%ROOT_FOLDER%' adminUsername: '%ADMIN_USERNAME%' adminPassword: '%ADMIN_PASSWORD%' adminPath: '/wp-admin'
The tests/wpunit.suite.yml file:
Codeception Test Suite Configuration## Suite for unit or integration tests that require WordPress functions and classes.
actor: WpunitTestermodules: enabled:
- WPLoader
- \Helper\Wpunit config: WPLoader: wpRootFolder: "%ROOT_FOLDER%" dbName: "%TEST_DB_NAME%" dbHost: "%DB_HOST%" dbUser: "%DB_USER%" dbPassword: "%DBPASSWORD%" tablePrefix: "wp" domain: "%DOMAIN%" adminEmail: "amdin@wplocal.local" title: "Test" plugins: ['test-plugin/plugin.php'] activatePlugins: ['test-plugin/plugin.php']
I had no issues running this test:
<?phpclass WPFirstCest { /* It should be able to reach the homepage @test */ public function should_be_able_to_reach_the_homepage( AcceptanceTester $I ) { $I->havePostInDatabase(['post_title' => 'A test post']); $I->amOnPage( '/' ); $I->see('A test post'); }}
Let me know if this helps you.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lucatume/wp-browser/issues/140#issuecomment-370153037, or mute the thread https://github.com/notifications/unsubscribe-auth/AByOfvoxQi33fG10RFEJZmXIoD44TImRks5taq5VgaJpZM4SKM99 .
-- Craig Martin Owner/Director, Performance Foundry http://performancefoundry.com
Owner, Indie Travel Media http://indietravelmedia.com
Any update on this one?
Hi,
I'm using the 10up local docker with everything as default.
I can install Codeception and wp-browser using composer following the QuickStart instructions and successfully use init wp-browser to scaffold things. The problem lies with running a basic acceptance test to look at the homepage.
In my browser, outside of docker, I access the homepage at
localhost
. Within docker, a curl of that fails.Within docker, I can see the homepage by using
curl nginx
.My acceptance.suite.yml file reads:
But
php vendor/codeception/codeception/codecept run acceptance
returns:(and the same for test 2). if I switch
localhost
fornginx
, I getI obviously need to do something to allow codeception / wp-browser to see the browser, but I'm stuck as to what that is. Any help appreciated.