PATH
, you should be able to run composer --version
at the terminal and see the version correctly.The version of MAMP used in this tutorial is the free, non PRO, one. MAMP PRO provides more features, but the setup instructions should remain valid.
/Applications/MAMP/htdocs
directory.
If your document root lies elsewhere, replace the /Applications/MAMP/htdocs
path with the actual directory in each command.http://localhost/phpMyAdmin/
page and create two new databases:wordpress
is the database you will use for WordPresstests
is the database you will use for the tests/Applications/MAMP/htdocs
and head over to http://localhost
to install WordPress.wordpress
root
root
localhost
admin
as administrator user name and password
as password for the administrator user.http://localhost
and that you can correctly access the administration area at http://localhost/wp-admin
.my-plugin
plugin./Applications/MAMP/htdocs/wp-content/plugins/my-plugin/my-plugin.php
file:http://localhost/wp-admin/plugins.php
.composer.json
file generated by the above answers:lucatume/wp-browser
as a development dependency:vendor/bin
folder.
To check Codeception is correctly installed run this command:Since wp-browser requires Codeception, there is no need to require Codeception explicitly as a development dependency.
http://localhost
.http://localhost/phpMyAdmin/
, under the "Export" tab:wp-browser
using its interactive mode:wp-browser
.y
y
acceptance
functional
wpunit
.env.testing
/Applications/MAMP/htdocs
/wp-admin
tests
localhost
root
root
wp_
tests
localhost
root
root
wp_
http://localhost
[email protected]
My Plugin Test
admin
password
plugin
my-plugin/my-plugin.php
no
Background
any scenario will share. In the case of a plugin the minimal, starting environment is the following:my-plugin
.http://localhost/wp-admin
.The following command will empty the site, backup any content you care about first!
http://localhost/phpMyAdmin/
and move the file to the /Applications/MAMP/htdocs/wp-content/plugins/my-plugin/tests/_data/dump.sql
directory.wp-config.php
file, to handle the requests made by the tests.acceptance
and functional
tests as tests
but, looking at the contents of the /Applications/MAMP/htdocs/wp-config.php
file, the DB_NAME
constant is set to wordpress
.wordpress
database.tests
database./Applications/MAMP/htdocs/wp-config.php
and replace the line defining the DB_NAME
constant like this:tests/acceptance.suite.yml
and tests/functional.suite.yml
files, respectively the acceptance
and functional
suite configuration files, you will see these entries in the WPBrowser
module configuration:$_SERVER['HTTP_X_TEST_REQUEST']
and $_SERVER['X_WPBROWSER_REQUEST']
variables.vendor/bin/codecept
to see a list of the available commands.